From 92c0d1e936e02563d1e45a033ac8080b45f951be Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 19 Oct 2026 12:23:08 -0400 Subject: [PATCH] Chrome: turning the File tab off closes a Backstage that is already open Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/lib.rs | 4 ++++ crates/ui-egui/tests/host_chrome.rs | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 3c6ed2b02..9adea9a08 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1129,6 +1129,10 @@ impl SheetApp { // The language the widgets translate with this frame (see `i18n::current`). i18n::set_current(&ctx, self.ui.language); let t = theme::Tokens::get(&ctx); + // A host can turn the File tab off while Backstage is already open: close it. + if !self.chrome.file_tab { + self.backstage = None; + } if self.backstage.is_none() { self.ribbon_keys(&ctx); } diff --git a/crates/ui-egui/tests/host_chrome.rs b/crates/ui-egui/tests/host_chrome.rs index 0773f4c49..627e24025 100644 --- a/crates/ui-egui/tests/host_chrome.rs +++ b/crates/ui-egui/tests/host_chrome.rs @@ -52,3 +52,14 @@ fn without_the_file_tab_the_backstage_view_never_opens() { assert!(h.state().backstage.is_none(), "so is every page, Print and Save As included"); assert!(h.query_by_label("AutoSave").is_some(), "the title bar can stay on its own"); } + +#[test] +fn turning_the_file_tab_off_closes_an_open_backstage() { + let mut h = harness(Chrome::default()); + h.state_mut().open_backstage(Page::Home); + h.run_steps(3); + assert!(h.state().backstage.is_some(), "Backstage opens with the File tab on"); + h.state_mut().chrome.file_tab = false; + h.run_steps(3); + assert!(h.state().backstage.is_none(), "and closes when the host turns the File tab off"); +}