fix: prevent autocomplete mouse hover from interfering with keyboard navigation #8617
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the issue where autocomplete items get automatically highlighted when the mouse cursor happens to be over them, even without any mouse movement. This was particularly problematic when users clicked into the input field to type, as the mouse would often be positioned over autocomplete items, causing unintended highlighting that interfered with keyboard navigation.
Problem
As reported in #8615, when the autocomplete menu opens and the mouse cursor happens to be over one of the items, it automatically highlights that entry instead of the topmost one - even if the mouse doesn't move. This breaks the expected behavior where pressing Enter should select the topmost result.
Solution
Implemented a smart hover detection system that distinguishes between:
Key Changes
hoveredIndex
andhasMouseMoved
state trackingBehavior
Testing
Fixes #8615
Important
Fixes autocomplete hover issue in
ContextMenu.tsx
by tracking mouse movement to prevent interference with keyboard navigation.ContextMenu.tsx
.hoveredIndex
andhasMouseMoved
state variables.handleMouseMove
to track mouse movement with a 5-pixel threshold.This description was created by
for 2a03b2b. You can customize this summary. It will automatically update as commits are pushed.