# Fix first LSP server item flickering and staying highlighted when hovering between multiple language server entries in the status bar menu \(\#61400\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 40dc154a7cc28270d2319873b0881ef053dc22b9

Requested commit: 40dc154a7cc28270d2319873b0881ef053dc22b9

Commit: 40dc154a7cc28270d2319873b0881ef053dc22b9

Tree: 018a7f63dd74271f39a9e05e531fa2e827a4f21d

Author: John

Committer: GitHub

## Message

```
Fix first LSP server item flickering and staying highlighted when hovering between multiple language server entries in the status bar menu (#61400)

# Objective

- When a submenu is open in a ContextMenu (e.g., an LSP server entry in
the status bar menu), focus moves from the main menu to the
submenu entity. Hovering over a different submenu trigger calls
`on_hover(true)` which runs `window.focus()` to return focus to the main
menu. This fires `on_focus_in`, which runs `select_toggled_or_first` →
`select_first`, re-selecting the first item. The same issue occurs
in `on_hover(false)` when the mouse leaves a trigger with an open
submenu.

## Solution

- Add a `suppress_focus_selection` flag to `ContextMenu`. Before each
`window.focus()` call in `on_hover` handlers, set the flag to
`true`. The `on_focus_in` callback checks this flag and skips
auto-selection when focus is returning from submenu interaction. The
flag is
reset to `false` after each `on_focus_in` invocation.

## Testing

- Tested manually by opening the LSP status bar menu with multiple
running language servers and hovering between server entries. The
first item no longer flickers or stays highlighted after hovering over
other items.

## Showcase
### before fixed


https://github.com/user-attachments/assets/26efb133-fb7e-4dbe-88b7-88d510dfd3a4



### after fixed


https://github.com/user-attachments/assets/7081c07d-d7f6-4a35-abe3-486bfba8591f


## Release Notes:
- Fixed a bug where the first LSP server item would flicker and stay
highlighted when hovering between multiple language server entries in
the status bar menu.
```

## Parents

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

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