diff options
Diffstat (limited to 'packages/ui/src/components')
| -rw-r--r-- | packages/ui/src/components/list.tsx | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/packages/ui/src/components/list.tsx b/packages/ui/src/components/list.tsx index 4f6df0faf..808c9b032 100644 --- a/packages/ui/src/components/list.tsx +++ b/packages/ui/src/components/list.tsx @@ -15,6 +15,7 @@ export interface ListProps<T> extends FilteredListProps<T> { children: (item: T) => JSX.Element emptyMessage?: string onKeyEvent?: (event: KeyboardEvent, item: T | undefined) => void + onMove?: (item: T | undefined) => void activeIcon?: IconProps["name"] filter?: string search?: ListSearchProps | boolean @@ -82,6 +83,13 @@ export function List<T>(props: ListProps<T> & { ref?: (ref: ListRef) => void }) element?.scrollIntoView({ block: "center", behavior: "smooth" }) }) + createEffect(() => { + const all = flat() + const current = active() + const item = all.find((x) => props.key(x) === current) + props.onMove?.(item) + }) + const handleSelect = (item: T | undefined, index: number) => { props.onSelect?.(item, index) } |
