# picker: Fix mouse overrides selected item highlight in searchable dropdown \(\#50827\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/56daf917dba26a24f26a64fbf3741222ae4edccb)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 56daf917dba26a24f26a64fbf3741222ae4edccb

Requested commit: 56daf917dba26a24f26a64fbf3741222ae4edccb

Commit: 56daf917dba26a24f26a64fbf3741222ae4edccb

Tree: 2138da1d6df6737ee6d9c6aa699f9e12f678d0c0

Author: Om Chillure

Committer: GitHub

## Message

```
picker: Fix mouse overrides selected item highlight in searchable dropdown (#50827)

### Fixes #31865

### Problem
When navigating a picker (command palette, file finder, etc.) with the
keyboard and then hovering with the mouse, two items would appear
highlighted at the same time - one from the keyboard selection
ghost_element_selected background and one from the CSS style
ghost_element_hover background. This happened because GPUI's CSS hover
is applied at paint time independently from the Rust selection state.

### Solution
Added a keyboard_navigated: bool flag to [Picker] to track whether the
last navigation was via keyboard or mouse.

When a keyboard navigation action fires (↑, ↓, Home, End, etc.),
`keyboard_navigated` is set to true. A transparent
`block_mouse_except_scroll` overlay div is added on top of each list
item, preventing the CSS style from firing on `ListItem` children.

When the mouse moves over any item, the overlay's `on_mouse_move`
handler fires, clears keyboard_navigated, moves the selection to that
item, and re-renders - removing all overlays and restoring normal mouse
hover behavior.
The `on_hover` handler also moves the selection to whichever item the
mouse enters, so mouse navigation is fully functional.
Clicks work through the overlay since `block_mouse_except_scroll` only
affects hover hit-testing, not click events on the parent div.

### Behavior
Matches VS Code / IntelliJ — keyboard navigation suppresses hover
highlights until the mouse moves, at which point normal hover resumes.
Only one item is ever highlighted at a time.

### Video

[Screencast from 2026-03-05
19-20-16.webm](https://github.com/user-attachments/assets/7a8a543a-95f3-481f-b59d-171604e5f883)

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
```

## Parents

- [f0625add66b1e29206a170c2f51c52950b32084c](https://git.cafe/gitcafe/zed/commit/f0625add66b1e29206a170c2f51c52950b32084c?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/56daf917dba26a24f26a64fbf3741222ae4edccb?format=markdown)
