Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Make close sidebar button work regardless of focus state (#52260)

Max Brunsfeld0b9aeaf663fa
diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs
index 121d44a8773..ff394ef30c4 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::<MultiWorkspace>().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 c89c587dd3c..652331bc724 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<Self>) {
+ pub fn close_sidebar(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.sidebar_open = false;
let has_notifications = self.sidebar_has_notifications(cx);
let show_toggle = self.multi_workspace_enabled(cx);