[PR #8797] fix(tui): prevent accidental hover selection in autocomplete menus #12873

Closed
opened 2026-02-16 18:17:45 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8797

State: closed
Merged: No


Problem 🔽

Autocomplete menus (@ and / in TUI) and dialog select components currently auto-select items when UI elements move under a stationary cursor. This creates two problematic scenarios:

  1. Menu appears under stationary cursor: When a menu opens, if the user's mouse happens to be over where an item renders, that item gets selected immediately even though the user hasn't moved the mouse
  2. Filter changes reorder items: When typing to filter, items shift position and if one lands under the stationary cursor, it gets auto-selected, breaking keyboard navigation

Users expect hover selection to activate only on intentional mouse movement, not when UI elements move under a stationary cursor.

https://github.com/user-attachments/assets/75582f1c-873e-4489-a361-17bf506f8404

Solution 🔽

https://github.com/user-attachments/assets/39fdf3e8-e3c7-4eb6-8ab8-ebcdceac0d18

Just checked, and it's fixed in the menu aswell:

https://github.com/user-attachments/assets/6c3afb9b-90b4-4ed6-a1cf-5c16cd934a97

The fix tracks actual mouse movement to distinguish between:

  • Intentional hover: User moves mouse → selection updates normally
  • Accidental hover: Menu appears/items reorder under stationary cursor → selection remains unchanged

This is implemented by:

  1. Setting a hasMouseMoved flag to false when menus open or filter text changes
  2. Listening for mousemove events to set the flag to true
  3. Only updating selection on hover when hasMouseMoved === true

Components updated:

  • Select.tsx: Dialog select menus
  • ChatInput.tsx: Autocomplete menus (@ and /)

This ensures hover selection only activates on deliberate user action, making keyboard navigation reliable and preventing surprising auto-selections.

Closes #8799

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8797 **State:** closed **Merged:** No --- # Problem 🔽 Autocomplete menus (`@` and `/` in TUI) and dialog select components currently auto-select items when UI elements move under a stationary cursor. This creates two problematic scenarios: 1. **Menu appears under stationary cursor**: When a menu opens, if the user's mouse happens to be over where an item renders, that item gets selected immediately even though the user hasn't moved the mouse 2. **Filter changes reorder items**: When typing to filter, items shift position and if one lands under the stationary cursor, it gets auto-selected, breaking keyboard navigation Users expect hover selection to activate only on **intentional mouse movement**, not when UI elements move under a stationary cursor. https://github.com/user-attachments/assets/75582f1c-873e-4489-a361-17bf506f8404 # Solution 🔽 https://github.com/user-attachments/assets/39fdf3e8-e3c7-4eb6-8ab8-ebcdceac0d18 Just checked, and it's fixed in the menu aswell: https://github.com/user-attachments/assets/6c3afb9b-90b4-4ed6-a1cf-5c16cd934a97 The fix tracks actual mouse movement to distinguish between: - **Intentional hover**: User moves mouse → selection updates normally - **Accidental hover**: Menu appears/items reorder under stationary cursor → selection remains unchanged This is implemented by: 1. Setting a `hasMouseMoved` flag to `false` when menus open or filter text changes 2. Listening for `mousemove` events to set the flag to `true` 3. Only updating selection on hover when `hasMouseMoved === true` Components updated: - `Select.tsx`: Dialog select menus - `ChatInput.tsx`: Autocomplete menus (`@` and `/`) This ensures hover selection only activates on deliberate user action, making keyboard navigation reliable and preventing surprising auto-selections. Closes #8799
yindo added the pull-request label 2026-02-16 18:17:45 -05:00
yindo closed this issue 2026-02-16 18:17:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12873