diff --git a/src/app/update/mod.rs b/src/app/update/mod.rs index a21d463d9..e0bbf7ca5 100644 --- a/src/app/update/mod.rs +++ b/src/app/update/mod.rs @@ -4633,7 +4633,7 @@ impl OpenCADStudio { Message::PropAttrCommit(tag) => self.on_prop_attr_commit(tag), Message::PropPointerPressed => { - if self.tabs[self.active_tab].is_start || self.clean_screen { + if !self.dock_panel_visible(crate::ui::dock::PanelId::Properties) { return Task::none(); } crate::ui::properties::sync_active_field_task() @@ -7531,3 +7531,41 @@ impl OpenCADStudio { } } } + +#[cfg(test)] +mod prop_pointer_tests { + use super::Message; + use crate::app::OpenCADStudio; + use crate::ui::dock::PanelId; + + fn drawing_app() -> OpenCADStudio { + let mut app = OpenCADStudio::new_for_test(); + app.automation_op(r#"{"op":"new"}"#); + app + } + + #[test] + fn hidden_properties_panel_skips_the_focus_sweep() { + // A click while the panel is closed must not run the widget-tree sweep: + // the returned task is a bare `Task::none` (units == 0). + let mut app = drawing_app(); + assert!(app.dock_panel_visible(PanelId::Properties)); + app.show_properties = false; + assert!(!app.dock_panel_visible(PanelId::Properties)); + + let task = app.update(Message::PropPointerPressed); + assert_eq!(task.units(), 0); + } + + #[test] + fn visible_properties_panel_runs_the_focus_sweep() { + // A click while the panel is open must still fire the sweep (units > 0) + // so the select-whole-value feature keeps working. + let mut app = drawing_app(); + app.show_properties = true; + assert!(app.dock_panel_visible(PanelId::Properties)); + + let task = app.update(Message::PropPointerPressed); + assert!(task.units() > 0); + } +}