From 335f46122b57c633bbabd4be10ff08688a6876d0 Mon Sep 17 00:00:00 2001 From: shuv <523952+kcrommett@users.noreply.github.com> Date: Tue, 25 Nov 2025 22:41:41 -0800 Subject: Add favorites to model selector (#23) (#4343) Co-authored-by: Github Action --- packages/ui/src/components/select-dialog.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'packages/ui/src') diff --git a/packages/ui/src/components/select-dialog.tsx b/packages/ui/src/components/select-dialog.tsx index c54f4ec9d..4806a12dd 100644 --- a/packages/ui/src/components/select-dialog.tsx +++ b/packages/ui/src/components/select-dialog.tsx @@ -14,6 +14,7 @@ interface SelectDialogProps emptyMessage?: string children: (item: T) => JSX.Element onSelect?: (value: T | undefined) => void + onKeyEvent?: (event: KeyboardEvent, item: T | undefined) => void } export function SelectDialog(props: SelectDialogProps) { @@ -65,9 +66,12 @@ export function SelectDialog(props: SelectDialogProps) { setStore("mouseActive", false) if (e.key === "Escape") return + const all = flat() + const selected = all.find((x) => others.key(x) === active()) + props.onKeyEvent?.(e, selected) + if (e.key === "Enter") { e.preventDefault() - const selected = flat().find((x) => others.key(x) === active()) if (selected) handleSelect(selected) } else { onKeyDown(e) -- cgit v1.2.3