zed/crates/command_palette
prayansh_chhablani 250022469d
Fix reopening and interacting with the command palette when its submenu is already open closing the palette (#54243)
Closes #10045

follow repro steps:
1. Open the command palette cmd-shift-p.
2. Locate and click language selector: toggle.
3. cmd-shift-p.
4. Click language selector: toggle.
5. Notice that the command palette is closed.

When the command palette is reopened on top of the already-open language
selector, the palette captures previous_focus_handle before the old
modal is hidden. In that case, previous_focus_handle refers to the
language selector picker, which is the correct previous focus at that
moment. The problem is that this modal is immediately dismissed (as the
language toggle gets hidden and command palette is shown in 3rd step)
and no longer exists by the time the selected command is confirmed.

Fix
Updated CommandPalette::toggle so that if another modal is already open,
it is dismissed first. Only after that dismissal completes does the
command palette capture window.focused(cx) as its previous_focus_handle.

This means the command palette now stores the real pre-palette focus
target, such as the editor or workspace, instead of storing focus from a
modal that is about to be removed.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [ ] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [ ] Performance impact has been considered and is acceptable

Release Notes:

- N/A or Added/Fixed/Improved ...

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-07-21 09:13:56 +00:00
..
src Fix reopening and interacting with the command palette when its submenu is already open closing the palette (#54243) 2026-07-21 09:13:56 +00:00
Cargo.toml fuzzy_nucleo: Add strings module and route several pickers through it (#54123) 2026-04-20 14:41:29 +02:00
LICENSE-GPL chore: Change AGPL-licensed crates to GPL (except for collab) (#4231) 2024-01-24 00:26:58 +01:00