From 4acb820e0191f7c13184dab49206148092b14dc7 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sun, 31 May 2026 14:57:50 +0300 Subject: [PATCH] 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 --- src/app/commands.rs | 3 +++ src/app/update.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/app/commands.rs b/src/app/commands.rs index ca7aa51cf..e929eca7b 100644 --- a/src/app/commands.rs +++ b/src/app/commands.rs @@ -7,6 +7,9 @@ use std::path::PathBuf; impl OpenCADStudio { pub(super) fn dispatch_command(&mut self, cmd: &str) -> Task { 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(); diff --git a/src/app/update.rs b/src/app/update.rs index 95c217f0e..2e192c8b3 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -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();