Skip to content

Commit 3051b9c

Browse files
authored
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" />
1 parent b3b8172 commit 3051b9c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

crates/ui/src/dock/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl DockItem {
410410
}
411411
}
412412
DockItem::Tiles { .. } => {}
413-
DockItem::Panel { .. } => {}
413+
DockItem::Panel { view } => view.set_active(!collapsed, window, cx),
414414
}
415415
}
416416

crates/ui/src/dock/stack_panel.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ impl Panel for StackPanel {
3535
fn title(&self, _window: &gpui::Window, _cx: &gpui::App) -> gpui::AnyElement {
3636
"StackPanel".into_any_element()
3737
}
38-
38+
fn set_active(&mut self, active: bool, window: &mut Window, cx: &mut App) {
39+
for panel in &self.panels {
40+
panel.set_active(active, window, cx);
41+
}
42+
}
3943
fn dump(&self, cx: &App) -> PanelState {
4044
let sizes = self.panel_group.read(cx).sizes();
4145
let mut state = PanelState::new(self);

crates/ui/src/dock/tab_panel.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,13 @@ impl TabPanel {
347347
pub(super) fn set_collapsed(
348348
&mut self,
349349
collapsed: bool,
350-
_: &mut Window,
350+
window: &mut Window,
351351
cx: &mut Context<Self>,
352352
) {
353353
self.collapsed = collapsed;
354+
if let Some(panel) = self.panels.get(self.active_ix) {
355+
panel.set_active(!collapsed, window, cx);
356+
}
354357
cx.notify();
355358
}
356359

0 commit comments

Comments
 (0)