(e: KeyboardEvent)
| 121 | backspaceExitsOnEmpty: false |
| 122 | }); |
| 123 | const handleKeyDown = (e: KeyboardEvent) => { |
| 124 | if (e.key === 'up' || e.ctrl && e.key === 'p') { |
| 125 | e.preventDefault(); |
| 126 | e.stopImmediatePropagation(); |
| 127 | step(direction === 'up' ? 1 : -1); |
| 128 | return; |
| 129 | } |
| 130 | if (e.key === 'down' || e.ctrl && e.key === 'n') { |
| 131 | e.preventDefault(); |
| 132 | e.stopImmediatePropagation(); |
| 133 | step(direction === 'up' ? -1 : 1); |
| 134 | return; |
| 135 | } |
| 136 | if (e.key === 'return') { |
| 137 | e.preventDefault(); |
| 138 | e.stopImmediatePropagation(); |
| 139 | const selected = items[focusedIndex]; |
| 140 | if (selected) onSelect(selected); |
| 141 | return; |
| 142 | } |
| 143 | if (e.key === 'tab') { |
| 144 | e.preventDefault(); |
| 145 | e.stopImmediatePropagation(); |
| 146 | const selected = items[focusedIndex]; |
| 147 | if (!selected) return; |
| 148 | const tabAction = e.shift ? onShiftTab ?? onTab : onTab; |
| 149 | if (tabAction) { |
| 150 | tabAction.handler(selected); |
| 151 | } else { |
| 152 | onSelect(selected); |
| 153 | } |
| 154 | } |
| 155 | }; |
| 156 | useEffect(() => { |
| 157 | onQueryChange(query); |
| 158 | setFocusedIndex(0); |
nothing calls this directly
no test coverage detected