diff options
| author | shuv <[email protected]> | 2025-11-25 22:41:41 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-26 00:41:41 -0600 |
| commit | 335f46122b57c633bbabd4be10ff08688a6876d0 (patch) | |
| tree | b091ffd7b47c16a051e74fbb684f1bfd7979272a /packages/ui/src/components | |
| parent | 73eae191e9de23905337ce507a4dd152880c4e5a (diff) | |
| download | opencode-335f46122b57c633bbabd4be10ff08688a6876d0.tar.gz opencode-335f46122b57c633bbabd4be10ff08688a6876d0.zip | |
Add favorites to model selector (#23) (#4343)
Co-authored-by: Github Action <[email protected]>
Diffstat (limited to 'packages/ui/src/components')
| -rw-r--r-- | packages/ui/src/components/select-dialog.tsx | 6 |
1 files changed, 5 insertions, 1 deletions
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<T> emptyMessage?: string children: (item: T) => JSX.Element onSelect?: (value: T | undefined) => void + onKeyEvent?: (event: KeyboardEvent, item: T | undefined) => void } export function SelectDialog<T>(props: SelectDialogProps<T>) { @@ -65,9 +66,12 @@ export function SelectDialog<T>(props: SelectDialogProps<T>) { 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) |
