Panels: a double-click on a tab of a group beside another no longer reports an error

This commit is contained in:
Marco Arnulfo
2026-10-24 02:05:18 +07:00
committed by bflatastic
parent 78396465a5
commit 35104e10ed
2 changed files with 23 additions and 0 deletions
+2
View File
@@ -1067,10 +1067,12 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) -> bool {
None => dock(ui),
};
// A double-click on a tab of the dock's tree collapses its group to its tabs, or expands it.
// A group beside another doesn't collapse, so its tabs ignore it rather than report an error.
if let Some(root) = &drawn.root {
let tabs = Layout { root: Some(root.clone()), floating: Vec::new() };
if let Some(panel) =
tabs.panels().into_iter().find(|p| ui.ctx().read_response(area.with(("tab", *p))).is_some_and(|r| r.double_clicked()))
&& tab_group_shortens(&tabs, panel) == Some(true)
{
content.commands.push(("window.panel.collapse", json!({"panel": panel})));
}
+21
View File
@@ -1012,6 +1012,27 @@ fn a_double_click_on_a_dock_tab_collapses_its_group_to_its_tabs_and_another_expa
assert!(valid(h.state().ui.docking.as_ref().unwrap()));
}
/// A double-click on a tab of a group beside another does nothing, and leaves no error in the
/// status bar: that group doesn't collapse (`a_group_beside_another_does_not_collapse`).
#[test]
fn a_double_click_on_a_tab_of_a_group_beside_another_does_nothing() {
let mut app = app();
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
app.run("window.panel.move", json!({"panel":"swatches", "anchor":"layers", "zone":"left"})).unwrap();
let saved = app.ui.docking.clone();
let mut h = harness(app, vec2(1280.0, 800.0));
let status = h.state().ui.status.clone();
let shown: Vec<&str> = root_groups(&h).iter().map(|g| g.shown).collect();
assert_eq!(shown.len(), 2, "{shown:?}");
for panel in shown {
let at = tab_center(&h, panel);
double_click(&mut h, at);
assert_eq!(h.state().ui.status, status, "no error: {panel}");
assert!(h.state().ui.docking_collapsed.is_empty(), "{panel}");
assert_eq!(h.state().ui.docking, saved, "{panel}");
}
}
/// A double-click on a tab of the legacy dock collapses the tabbed group to its tabs.
#[test]
fn a_double_click_on_a_legacy_dock_tab_collapses_the_tabbed_group() {