mirror of
https://github.com/storytold/craft-libs.git
synced 2026-10-31 15:49:54 +00:00
docking: window.panel.minimize toggles an accordion entry both ways
Without minimized the command read only dock and floating groups, so a closed accordion entry stayed closed.
This commit is contained in:
1 parent
5d5d11f854
commit
b64cc4eac6
2 files changed
+19
-1
No files matched your search
@@ -426,7 +426,14 @@ impl<P: Clone + Eq + Hash> DockCommand<P> {
|
||||
Self::CloseOthers { panel } => one(Action::CloseOthers { panel: panel.clone() }),
|
||||
Self::Minimize { panel, minimized } => {
|
||||
let place = layout.place(panel).ok_or(DockError::MissingPanel)?;
|
||||
let current = layout.group(&place).is_some_and(|g| g.minimized);
|
||||
// An accordion entry is minimized while it is closed.
|
||||
let current = match &place {
|
||||
Place::Node(path) => match layout.root.as_ref().and_then(|root| super::dock_model::node_at(root, path)) {
|
||||
Some(super::Node::Stack { entries }) => entries.iter().any(|e| &e.panel == panel && !e.open),
|
||||
_ => false,
|
||||
},
|
||||
place => layout.group(place).is_some_and(|g| g.minimized),
|
||||
};
|
||||
one(Action::SetMinimized { panel: panel.clone(), minimized: minimized.unwrap_or(!current) })
|
||||
}
|
||||
Self::Iconic { panel, iconic } => {
|
||||
|
||||
@@ -381,3 +381,14 @@ fn dock_to_a_side_without_a_dock_takes_one_panel_out_of_a_shared_group() {
|
||||
assert_eq!(side("layers"), Some(Side::End));
|
||||
assert_eq!(side("channels"), Some(Side::Start));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn minimize_without_a_value_toggles_an_accordion_entry_both_ways() {
|
||||
let entry = |panel: &str| StackEntry { panel: s(panel), open: true, height: None };
|
||||
let mut workspace = Workspace::new(Layout { root: Some(Node::Stack { entries: vec![entry("layers"), entry("history")] }), floating: Vec::new() });
|
||||
let toggle = parse(json!({"command": "window.panel.minimize", "panel": "layers"})).unwrap();
|
||||
toggle.apply(&mut workspace, false, &space(), permissions).unwrap();
|
||||
assert_eq!(workspace.layout.panel_state(&s("layers")), PanelState::Open);
|
||||
toggle.apply(&mut workspace, false, &space(), permissions).unwrap();
|
||||
assert_eq!(workspace.layout.panel_state(&s("layers")), PanelState::Front);
|
||||
}
|
||||
Reference in new issue
Block a user