dock: Bind actions only when the tab panel is not collapsed (#964)

This commit is contained in:
Floyd Wang 2025-06-17 13:38:24 +08:00 committed by GitHub
parent f183236d52
commit 56e282315d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,7 +2,7 @@ use std::sync::Arc;
use gpui::{ use gpui::{
div, prelude::FluentBuilder, px, relative, rems, App, AppContext, Context, Corner, div, prelude::FluentBuilder, px, relative, rems, App, AppContext, Context, Corner,
DismissEvent, DragMoveEvent, Empty, Entity, EventEmitter, FocusHandle, Focusable, DismissEvent, Div, DragMoveEvent, Empty, Entity, EventEmitter, FocusHandle, Focusable,
InteractiveElement as _, IntoElement, ParentElement, Pixels, Render, ScrollHandle, InteractiveElement as _, IntoElement, ParentElement, Pixels, Render, ScrollHandle,
SharedString, StatefulInteractiveElement, StyleRefinement, Styled, WeakEntity, Window, SharedString, StatefulInteractiveElement, StyleRefinement, Styled, WeakEntity, Window,
}; };
@ -1108,6 +1108,14 @@ impl TabPanel {
}); });
} }
} }
// Bind actions to the tab panel, only when the tab panel is not collapsed.
fn bind_actions(&self, cx: &mut Context<Self>) -> Div {
v_flex().when(!self.collapsed, |this| {
this.on_action(cx.listener(Self::on_action_toggle_zoom))
.on_action(cx.listener(Self::on_action_close_panel))
})
}
} }
impl Focusable for TabPanel { impl Focusable for TabPanel {
@ -1139,11 +1147,9 @@ impl Render for TabPanel {
state.closable = false; state.closable = false;
} }
v_flex() self.bind_actions(cx)
.id("tab-panel") .id("tab-panel")
.track_focus(&focus_handle) .track_focus(&focus_handle)
.on_action(cx.listener(Self::on_action_toggle_zoom))
.on_action(cx.listener(Self::on_action_close_panel))
.size_full() .size_full()
.overflow_hidden() .overflow_hidden()
.bg(cx.theme().background) .bg(cx.theme().background)