# ui: Dismiss context menus when window loses focus \(\#46866\) · gitcafe/zed

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

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

Visibility: public

Requested revision: d139c5e6d20e293cd5977918db7a1a83f1dc90e9

Requested commit: d139c5e6d20e293cd5977918db7a1a83f1dc90e9

Commit: d139c5e6d20e293cd5977918db7a1a83f1dc90e9

Tree: 3b46fc0163fb002826c837e2a04b2f2fa67986bf

Author: Jake Go

Committer: GitHub

## Message

```
ui: Dismiss context menus when window loses focus (#46866)

Context menus close when the window becomes inactive (e.g., clicking to
another window or app). Previously, menus would remain visible until the
window regained focus.

This aligns Zed's context menu behavior with native macOS apps, where
NSMenu automatically dismisses when the window loses focus. Users expect
menus to close when switching windows or apps.

Uses `observe_window_activation` to detect when the window becomes
inactive and calls `cancel` to dismiss the menu.

Release Notes:

- Fixed context menus dismiss/cancel when the window loses focus

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
```

## Parents

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

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