dock: Fix to sync active state to panels when collapse dock. (#770)

This is a continuation of #764
Without this, if we drag webview to sidebar and collapse, webview is not
aware of itself being hidden
<img width="994" alt="image"
src="https://github.com/user-attachments/assets/6d8d66d1-2a9b-472a-a42f-d04b47aefaac"
/>
This commit is contained in:
Jakku Sakura 2025-04-03 13:13:29 +08:00 committed by GitHub
parent b3b8172349
commit 3051b9c1c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 3 deletions

View file

@ -410,7 +410,7 @@ impl DockItem {
}
}
DockItem::Tiles { .. } => {}
DockItem::Panel { .. } => {}
DockItem::Panel { view } => view.set_active(!collapsed, window, cx),
}
}

View file

@ -35,7 +35,11 @@ impl Panel for StackPanel {
fn title(&self, _window: &gpui::Window, _cx: &gpui::App) -> gpui::AnyElement {
"StackPanel".into_any_element()
}
fn set_active(&mut self, active: bool, window: &mut Window, cx: &mut App) {
for panel in &self.panels {
panel.set_active(active, window, cx);
}
}
fn dump(&self, cx: &App) -> PanelState {
let sizes = self.panel_group.read(cx).sizes();
let mut state = PanelState::new(self);

View file

@ -347,10 +347,13 @@ impl TabPanel {
pub(super) fn set_collapsed(
&mut self,
collapsed: bool,
_: &mut Window,
window: &mut Window,
cx: &mut Context<Self>,
) {
self.collapsed = collapsed;
if let Some(panel) = self.panels.get(self.active_ix) {
panel.set_active(!collapsed, window, cx);
}
cx.notify();
}