diff options
| author | Adam <[email protected]> | 2025-12-29 09:47:53 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2025-12-29 09:47:57 -0600 |
| commit | 831e9bce51c035ec22ce9562bf0257d6b59b2fe4 (patch) | |
| tree | b6e86b44cbc980d737a63cb571cb61a9003d237b /packages/ui/src/hooks | |
| parent | 5de73abd820d9425e82f85f95f50568332ca7cdc (diff) | |
| download | opencode-831e9bce51c035ec22ce9562bf0257d6b59b2fe4.tar.gz opencode-831e9bce51c035ec22ce9562bf0257d6b59b2fe4.zip | |
fix(desktop): jankiness
Diffstat (limited to 'packages/ui/src/hooks')
| -rw-r--r-- | packages/ui/src/hooks/use-filtered-list.tsx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/packages/ui/src/hooks/use-filtered-list.tsx b/packages/ui/src/hooks/use-filtered-list.tsx index 76a5ae84f..416f030ef 100644 --- a/packages/ui/src/hooks/use-filtered-list.tsx +++ b/packages/ui/src/hooks/use-filtered-list.tsx @@ -51,9 +51,17 @@ export function useFilteredList<T>(props: FilteredListProps<T>) { ) }) + function initialActive() { + if (props.current) return props.key(props.current) + + const items = flat() + if (items.length === 0) return "" + return props.key(items[0]) + } + const list = createList({ items: () => flat().map(props.key), - initialActive: props.current ? props.key(props.current) : props.key(flat()[0]), + initialActive: initialActive(), loop: true, }) |
