Make close sidebar button work regardless of focus state (#52260)
Max Brunsfeld
created
Like https://github.com/zed-industries/zed/pull/52045, but for the
*close* button.
Release Notes:
- N/A
Change summary
crates/sidebar/src/sidebar.rs | 6 +++++-
crates/workspace/src/multi_workspace.rs | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
Detailed changes
@@ -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);
+ });
+ }
})
}
}
@@ -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);