fix(omnibox): enable keyboard navigation in favorites view with empty input
Arrow keys and Enter key now work correctly in favorites view when input is empty. Previously, these keys only worked with suggestions, not favorites.
- commit
- b21627f725caf45a8c688c40b27c0a8546455118
- author
- bnema · · 2025-11-16 18:39 UTC
- committer
- bnema · · 2025-11-16 19:18 UTC
- parent
- 85bc96a
- signature
- unsigned
1 file · +11 -3
M gui/src/components/omnibox/OmniboxInput.svelte +11 -3
| @@ -185,8 +185,10 @@ | |||
| 185 | 185 | // Handle Enter key based on mode | |
| 186 | 186 | function handleEnterKey(event: KeyboardEvent) { | |
| 187 | 187 | if (mode === 'omnibox') { | |
| 188 | - | const selectedSuggestion = selectedIndex >= 0 ? suggestions[selectedIndex] : null; | |
| 189 | - | const url = selectedSuggestion?.url || inputValue || ''; | |
| 188 | + | // Get selected item from current view (history or favorites) | |
| 189 | + | const currentList = viewMode === 'history' ? suggestions : favorites; | |
| 190 | + | const selectedItem = selectedIndex >= 0 ? currentList[selectedIndex] : null; | |
| 191 | + | const url = selectedItem?.url || inputValue || ''; | |
| 190 | 192 | ||
| 191 | 193 | if (url) { | |
| 192 | 194 | omniboxBridge.navigate(url); | |
| @@ -233,7 +235,13 @@ | |||
| 233 | 235 | ||
| 234 | 236 | // Handle arrow key navigation | |
| 235 | 237 | function handleArrowKeys(key: string) { | |
| 236 | - | const totalItems = mode === 'omnibox' ? suggestions.length : matches.length; | |
| 238 | + | let totalItems: number; | |
| 239 | + | if (mode === 'omnibox') { | |
| 240 | + | // Get count from current view (history or favorites) | |
| 241 | + | totalItems = viewMode === 'history' ? suggestions.length : favorites.length; | |
| 242 | + | } else { | |
| 243 | + | totalItems = matches.length; | |
| 244 | + | } | |
| 237 | 245 | ||
| 238 | 246 | if (totalItems > 0) { | |
| 239 | 247 | if (key === 'ArrowDown') { | |
| @@ -185,8 +185,10 @@ | |||||
| 185 | // Handle Enter key based on mode | 185 | // Handle Enter key based on mode | ||
| 186 | function handleEnterKey(event: KeyboardEvent) { | 186 | function handleEnterKey(event: KeyboardEvent) { | ||
| 187 | if (mode === 'omnibox') { | 187 | if (mode === 'omnibox') { | ||
| 188 | - | const selectedSuggestion = selectedIndex >= 0 ? suggestions[selectedIndex] : null; | 188 | + | // Get selected item from current view (history or favorites) |
| 189 | - | const url = selectedSuggestion?.url || inputValue || ''; | 189 | + | const currentList = viewMode === 'history' ? suggestions : favorites; |
| 190 | + | const selectedItem = selectedIndex >= 0 ? currentList[selectedIndex] : null; | |||
| 191 | + | const url = selectedItem?.url || inputValue || ''; | |||
| 190 | 192 | ||||
| 191 | if (url) { | 193 | if (url) { | ||
| 192 | omniboxBridge.navigate(url); | 194 | omniboxBridge.navigate(url); | ||
| @@ -233,7 +235,13 @@ | |||||
| 233 | 235 | ||||
| 234 | // Handle arrow key navigation | 236 | // Handle arrow key navigation | ||
| 235 | function handleArrowKeys(key: string) { | 237 | function handleArrowKeys(key: string) { | ||
| 236 | - | const totalItems = mode === 'omnibox' ? suggestions.length : matches.length; | 238 | + | let totalItems: number; |
| 239 | + | if (mode === 'omnibox') { | |||
| 240 | + | // Get count from current view (history or favorites) | |||
| 241 | + | totalItems = viewMode === 'history' ? suggestions.length : favorites.length; | |||
| 242 | + | } else { | |||
| 243 | + | totalItems = matches.length; | |||
| 244 | + | } | |||
| 237 | 245 | ||||
| 238 | if (totalItems > 0) { | 246 | if (totalItems > 0) { | ||
| 239 | if (key === 'ArrowDown') { | 247 | if (key === 'ArrowDown') { | ||