mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-01 14:16:49 -06:00
#1311: window.panel closes the panel's open flyout
Choosing a panel whose iconic-column flyout is open closes the flyout, as clicking its icon does.
This commit is contained in:
@@ -446,7 +446,15 @@ pub(crate) fn command(app: &mut DesignApp, id: &str, params: &Value) -> Option<R
|
||||
return Some(result);
|
||||
}
|
||||
// Float-only panels (Type › Tabs) are not in the layout.
|
||||
params.get("panel").and_then(Value::as_str).and_then(normalize)?;
|
||||
let panel = params.get("panel").and_then(Value::as_str).and_then(normalize)?;
|
||||
// Choosing a panel whose flyout is open closes the flyout, as the panel's icon does.
|
||||
if app.ui.docking_flyout.as_deref() == Some(panel) && in_iconic_column(&layout_of(app), panel) {
|
||||
app.ui.docking_flyout = None;
|
||||
if let Some(ctx) = app.egui_ctx.as_ref() {
|
||||
craft_ui::docking::close_flyout::<String>(ctx, area_id());
|
||||
}
|
||||
return Some(Ok(json!({"layout": layout_of(app), "closed": [], "floating": floating_panels(app)})));
|
||||
}
|
||||
return Some(shared_command(app, "window.panel.activate", params));
|
||||
}
|
||||
let id = shared_id(id)?;
|
||||
|
||||
@@ -602,6 +602,12 @@ fn collapse_to_icons_shrinks_the_dock_to_its_icons() {
|
||||
assert_eq!(app.ui.docking_raise.as_deref(), Some("pages"));
|
||||
assert!(showing(&app, "pages"));
|
||||
assert!(in_iconic_column(app.ui.docking.as_ref().unwrap(), "pages"));
|
||||
// Choosing it again closes the flyout, and a third time opens it again.
|
||||
app.run("window.panel", json!({"panel":"pages"})).unwrap();
|
||||
assert_eq!(app.ui.docking_flyout, None);
|
||||
assert!(!showing(&app, "pages"));
|
||||
app.run("window.panel", json!({"panel":"pages"})).unwrap();
|
||||
assert_eq!(app.ui.docking_flyout.as_deref(), Some("pages"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user