fix(properties): close the color dropdown on selection change and viewport click

The Properties color dropdown stayed open after deselecting, reselecting, or
clicking into the viewport. refresh_properties carried color_picker_open across
rebuilds, so a selection change never closed it; and a viewport press starts a
box selection, so it only closed on the second click. Stop preserving the
picker state across rebuilds and dismiss both color dropdowns on the first
viewport press.

Fixes #104.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-16 04:02:46 +03:00
1 parent 25bf371290
commit 6376080336
2 files changed
+8 -2

No files matched your search

+3 -2
View File
@@ -10,7 +10,9 @@ impl OpenCADStudio {
/// Preserves UI state (open pickers, edit buffer) across refreshes.
pub(super) fn refresh_properties(&mut self) {
let i = self.active_tab;
let color_picker_open = self.tabs[i].properties.color_picker_open;
// Note: the color-picker dropdown is intentionally NOT carried over — a
// rebuild means the selection (or a property) changed, so the dropdown
// closes, matching the deselect / reselect / click-away expectation.
let color_palette_open = self.tabs[i].properties.color_palette_open;
let edit_buf = std::mem::take(&mut self.tabs[i].properties.edit_buf);
let selected_group = self.tabs[i].properties.selected_group.clone();
@@ -307,7 +309,6 @@ impl OpenCADStudio {
}
}
};
panel.color_picker_open = color_picker_open;
panel.color_palette_open = color_palette_open;
panel.edit_buf = edit_buf;
panel
+5
View File
@@ -2779,6 +2779,11 @@ impl OpenCADStudio {
// (e.g. the annotation style combo), which has no backdrop of
// its own to catch outside clicks.
self.ribbon.close_dropdown();
// Likewise dismiss the Properties color dropdowns — a viewport
// press starts a box selection, so without this they'd only
// close on the second click (issue #104).
self.tabs[i].properties.color_picker_open = false;
self.tabs[i].properties.color_palette_open = false;
// Click anywhere outside the popup dismisses it. The
// menu's own buttons live above this mouse_area, so a
// press that reaches here means the cursor is not on