diff options
| author | Adam <[email protected]> | 2025-12-11 03:13:08 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2025-12-11 06:48:59 -0600 |
| commit | 1980113ee4305844803f866aef05d742f7cffd47 (patch) | |
| tree | da957fc920b24ab9b35cbcdc1b41d525824a833e /packages/ui/src | |
| parent | 85c0311d38c47c41e89f6b9cd7d3a0cfc4348841 (diff) | |
| download | opencode-1980113ee4305844803f866aef05d742f7cffd47.tar.gz opencode-1980113ee4305844803f866aef05d742f7cffd47.zip | |
wip(desktop): progress
Diffstat (limited to 'packages/ui/src')
| -rw-r--r-- | packages/ui/src/components/list.tsx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/packages/ui/src/components/list.tsx b/packages/ui/src/components/list.tsx index a7f2db9ef..013767e60 100644 --- a/packages/ui/src/components/list.tsx +++ b/packages/ui/src/components/list.tsx @@ -65,8 +65,8 @@ export function List<T>(props: ListProps<T> & { ref?: (ref: ListRef) => void }) element?.scrollIntoView({ block: "nearest", behavior: "smooth" }) }) - const handleSelect = (item: T | undefined) => { - props.onSelect?.(item) + const handleSelect = (item: T | undefined, index: number) => { + props.onSelect?.(item, index) } const handleKey = (e: KeyboardEvent) => { @@ -75,11 +75,12 @@ export function List<T>(props: ListProps<T> & { ref?: (ref: ListRef) => void }) const all = flat() const selected = all.find((x) => props.key(x) === active()) + const index = selected ? all.indexOf(selected) : -1 props.onKeyEvent?.(e, selected) if (e.key === "Enter") { e.preventDefault() - if (selected) handleSelect(selected) + if (selected) handleSelect(selected, index) } else { onKeyDown(e) } @@ -110,13 +111,13 @@ export function List<T>(props: ListProps<T> & { ref?: (ref: ListRef) => void }) </Show> <div data-slot="list-items"> <For each={group.items}> - {(item) => ( + {(item, i) => ( <button data-slot="list-item" data-key={props.key(item)} data-active={props.key(item) === active()} data-selected={item === props.current} - onClick={() => handleSelect(item)} + onClick={() => handleSelect(item, i())} onMouseMove={() => { setStore("mouseActive", true) setActive(props.key(item)) |
