VitePress' Local Search has a built-in check to disable hovering search results using the mouse when the most recent interaction was keyboard navigation.
However, this protection does not go far enough to cover one other common scenario: The mouse cursor is also interacting with results that appear underneath it, if the search is opened with the ⌘K/Ctrl + K keyboard shortcut.
I think this problem is a lot easier to grasp with this short video, straight from a freshly initialized VitePress project with just the search added:
Open the search with the ⌘K/Ctrl + K keyboard shortcut.
Type something to search, e.g. "vite"
Move your mouse cursor over the second item.
Close the search box using the Esc key.
Re-open search using the shortcut. The second item will be focused immediately.
Expected behavior
Expectation in keyboard-only navigation of a classic combobox would be to have initial focus in (or near to) the input field and move focus from there.
Describe the bug
VitePress' Local Search has a built-in check to disable hovering search results using the mouse when the most recent interaction was keyboard navigation.
However, this protection does not go far enough to cover one other common scenario: The mouse cursor is also interacting with results that appear underneath it, if the search is opened with the ⌘K/Ctrl + K keyboard shortcut.
I think this problem is a lot easier to grasp with this short video, straight from a freshly initialized VitePress project with just the search added:
https://github.com/user-attachments/assets/05a6496a-bffe-4d24-9daf-34f82fbed18b
Note how the second result is immediately focused, without the cursor even appearing (since macOS hides it when starting to type.)
In contrast, this is how the Algolia search behaves:
https://github.com/user-attachments/assets/ff50900a-2b5d-4117-a407-712bd718b851
Here, the active result item only changes once the mouse is moved.
Reproduction
Expected behavior
Expectation in keyboard-only navigation of a classic combobox would be to have initial focus in (or near to) the input field and move focus from there.
System Info
Additional context
I'd be happy to contribute a PR solving this issue.
Validations