From 5f10547cc3755a44251546dcbdd5f3c4e939861e Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 10 Apr 2026 01:36:15 -0700 Subject: [PATCH] Dismiss the context menu on interaction (#53599) Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A --- crates/sidebar/src/sidebar.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs index 9c126929a4705de4d3ffc9e6472332e86a07c2e8..4d88ddeffdd6625768dd0207176c0984e9833a29 100644 --- a/crates/sidebar/src/sidebar.rs +++ b/crates/sidebar/src/sidebar.rs @@ -1759,6 +1759,7 @@ impl Sidebar { let menu = ContextMenu::build_persistent(window, cx, move |menu, _window, menu_cx| { + let weak_menu = menu_cx.weak_entity(); let mut menu = menu .header("Project Folders") .end_slot_action(Box::new(menu::EndSlot)); @@ -1771,6 +1772,7 @@ impl Sidebar { let path = path.clone(); let project_group_key = project_group_key.clone(); let multi_workspace = multi_workspace.clone(); + let weak_menu = weak_menu.clone(); menu = menu.entry_with_end_slot_on_hover( name.clone(), None, @@ -1787,6 +1789,7 @@ impl Sidebar { ); }) .ok(); + weak_menu.update(cx, |_, cx| cx.emit(DismissEvent)).ok(); }, ); } @@ -1797,6 +1800,7 @@ impl Sidebar { { let project_group_key = project_group_key.clone(); let multi_workspace = multi_workspace.clone(); + let weak_menu = weak_menu.clone(); move |window, cx| { multi_workspace .update(cx, |multi_workspace, cx| { @@ -1807,13 +1811,13 @@ impl Sidebar { ); }) .ok(); + weak_menu.update(cx, |_, cx| cx.emit(DismissEvent)).ok(); } }, ); let project_group_key = project_group_key.clone(); let multi_workspace = multi_workspace.clone(); - let weak_menu = menu_cx.weak_entity(); menu.separator() .entry("Remove Project", None, move |window, cx| { multi_workspace