fix(app): support ctrl-n/p in lists (#10036)
This commit is contained in:
@@ -82,6 +82,15 @@ export function useFilteredList<T>(props: FilteredListProps<T>) {
|
|||||||
const selectedIndex = flat().findIndex((x) => props.key(x) === list.active())
|
const selectedIndex = flat().findIndex((x) => props.key(x) === list.active())
|
||||||
const selected = flat()[selectedIndex]
|
const selected = flat()[selectedIndex]
|
||||||
if (selected) props.onSelect?.(selected, selectedIndex)
|
if (selected) props.onSelect?.(selected, selectedIndex)
|
||||||
|
} else if (event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey) {
|
||||||
|
if (event.key === "n" || event.key === "p") {
|
||||||
|
event.preventDefault()
|
||||||
|
const navEvent = new KeyboardEvent("keydown", {
|
||||||
|
key: event.key === "n" ? "ArrowDown" : "ArrowUp",
|
||||||
|
bubbles: true,
|
||||||
|
})
|
||||||
|
list.onKeyDown(navEvent)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Skip list navigation for text editing shortcuts (e.g., Option+Arrow, Option+Backspace on macOS)
|
// Skip list navigation for text editing shortcuts (e.g., Option+Arrow, Option+Backspace on macOS)
|
||||||
if (event.altKey || event.metaKey) return
|
if (event.altKey || event.metaKey) return
|
||||||
|
|||||||
Reference in New Issue
Block a user