fix(ribbon): dismiss stuck style dropdown on viewport click

The annotation style combo renders its panel inline with no backdrop to
catch outside clicks, so it stayed open after clicking into the viewport
or starting another tool. Close any open ribbon dropdown on viewport
press (left/right/middle) and on command dispatch.

Fixes #50

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-05-31 14:57:50 +03:00
1 parent 83d36e02e3
commit 4acb820e01
2 files changed
+9

No files matched your search

+3
View File
@@ -7,6 +7,9 @@ use std::path::PathBuf;
impl OpenCADStudio {
pub(super) fn dispatch_command(&mut self, cmd: &str) -> Task<Message> {
let i = self.active_tab;
// Starting a command closes any open ribbon dropdown (e.g. a style
// combo left open) so it does not stay stuck behind the new tool.
self.ribbon.close_dropdown();
// Cancel any running command before starting a new one.
if self.tabs[i].active_cmd.is_some() {
self.tabs[i].scene.clear_preview_wire();
+6
View File
@@ -2297,6 +2297,10 @@ impl OpenCADStudio {
Message::ViewportLeftPress => {
let i = self.active_tab;
// A click in the viewport dismisses any open ribbon dropdown
// (e.g. the annotation style combo), which has no backdrop of
// its own to catch outside clicks.
self.ribbon.close_dropdown();
// 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
@@ -3062,6 +3066,7 @@ impl OpenCADStudio {
Message::ViewportRightPress => {
let i = self.active_tab;
self.ribbon.close_dropdown();
let mut sel = self.tabs[i].scene.selection.borrow_mut();
let Some(p) = sel.last_move_pos else {
return Task::none();
@@ -3095,6 +3100,7 @@ impl OpenCADStudio {
Message::ViewportMiddlePress => {
let i = self.active_tab;
self.ribbon.close_dropdown();
let now = Instant::now();
let is_double = {
let sel = self.tabs[i].scene.selection.borrow();