Contextual ribbon tab follows the active document

Every message that makes another document active (switching, opening,
creating or closing a tab) resyncs the contextual tab with that document's
selection, so a tab offered for one drawing no longer stays on another.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-09-25 13:56:13 +03:00
1 parent 68721813f4
commit 5d3987791e
1 file changed
+12
+12
View File
@@ -318,6 +318,18 @@ impl OpenCADStudio {
}
pub fn update(&mut self, msg: Message) -> Task<Message> {
// Whatever makes another document active (switching, opening,
// creating or closing a tab), the contextual ribbon tab follows that
// document's selection.
let before = self.tabs.get(self.active_tab).map(|tab| tab.id);
let task = self.update_message(msg);
if self.tabs.get(self.active_tab).map(|tab| tab.id) != before {
self.sync_underlay_tab();
}
task
}
fn update_message(&mut self, msg: Message) -> Task<Message> {
if let Some(tab) = self.tabs.get(self.active_tab) {
crate::entities::common::set_unit_context(
crate::entities::common::UnitContext::from_header(&tab.scene.document.header),