From 0b9aeaf663fa9a8a55d484eb60349e937bcb2b78 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 23 Mar 2026 14:35:10 -0700 Subject: [PATCH] Make close sidebar button work regardless of focus state (#52260) Like https://github.com/zed-industries/zed/pull/52045, but for the *close* button. Release Notes: - N/A --- crates/sidebar/src/sidebar.rs | 6 +++++- crates/workspace/src/multi_workspace.rs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs index 121d44a877323d2285556d05f3e36bd85ef06eb9..ff394ef30c4bb129cf0fabab4ac70c38c62f1350 100644 --- a/crates/sidebar/src/sidebar.rs +++ b/crates/sidebar/src/sidebar.rs @@ -2916,7 +2916,11 @@ impl Sidebar { .into_any_element() })) .on_click(|_, window, cx| { - window.dispatch_action(ToggleWorkspaceSidebar.boxed_clone(), cx); + if let Some(multi_workspace) = window.root::().flatten() { + multi_workspace.update(cx, |multi_workspace, cx| { + multi_workspace.close_sidebar(window, cx); + }); + } }) } } diff --git a/crates/workspace/src/multi_workspace.rs b/crates/workspace/src/multi_workspace.rs index c89c587dd3c40b1a947bc4696326217fec065d76..652331bc724a18b4f8cef20ba6ca41037af929eb 100644 --- a/crates/workspace/src/multi_workspace.rs +++ b/crates/workspace/src/multi_workspace.rs @@ -278,7 +278,7 @@ impl MultiWorkspace { cx.notify(); } - fn close_sidebar(&mut self, window: &mut Window, cx: &mut Context) { + pub fn close_sidebar(&mut self, window: &mut Window, cx: &mut Context) { self.sidebar_open = false; let has_notifications = self.sidebar_has_notifications(cx); let show_toggle = self.multi_workspace_enabled(cx);