@@ -26,6 +26,8 @@ actions!(
[
/// Toggles the workspace switcher sidebar.
ToggleWorkspaceSidebar,
+ /// Closes the workspace sidebar.
+ CloseWorkspaceSidebar,
/// Moves focus to or from the workspace sidebar without closing it.
FocusWorkspaceSidebar,
]
@@ -217,6 +219,16 @@ impl MultiWorkspace {
}
}
+ pub fn close_sidebar_action(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+ if !self.multi_workspace_enabled(cx) {
+ return;
+ }
+
+ if self.sidebar_open {
+ self.close_sidebar(window, cx);
+ }
+ }
+
pub fn focus_sidebar(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if !self.multi_workspace_enabled(cx) {
return;
@@ -738,6 +750,11 @@ impl Render for MultiWorkspace {
this.toggle_sidebar(window, cx);
},
))
+ .on_action(cx.listener(
+ |this: &mut Self, _: &CloseWorkspaceSidebar, window, cx| {
+ this.close_sidebar_action(window, cx);
+ },
+ ))
.on_action(cx.listener(
|this: &mut Self, _: &FocusWorkspaceSidebar, window, cx| {
this.focus_sidebar(window, cx);
@@ -27,8 +27,8 @@ mod workspace_settings;
pub use crate::notifications::NotificationFrame;
pub use dock::Panel;
pub use multi_workspace::{
- DraggedSidebar, FocusWorkspaceSidebar, MultiWorkspace, MultiWorkspaceEvent, Sidebar,
- SidebarHandle, ToggleWorkspaceSidebar,
+ CloseWorkspaceSidebar, DraggedSidebar, FocusWorkspaceSidebar, MultiWorkspace,
+ MultiWorkspaceEvent, Sidebar, SidebarHandle, ToggleWorkspaceSidebar,
};
pub use path_list::{PathList, SerializedPathList};
pub use toast_layer::{ToastAction, ToastLayer, ToastView};