From fa6096e21bf7e941648470ab262010bcb2f5830c Mon Sep 17 00:00:00 2001 From: Tiago Pereira <1698241+tiper@users.noreply.github.com> Date: Wed, 18 Nov 2026 23:35:57 +0000 Subject: [PATCH 1/2] Go to Movie keeps the card's focus while its menu closes Picking Go to Movie or Go to Show in an item's hold menu ran the page under the menu to its top as the menu closed, and BACK from the opened page came back to the top instead of the card. The menu parks its own Dismiss and the app then parks the Push, both captured while the menu's row held focus. The Dismiss commits first, so by the Push the closing menu no longer owns input, and Navigation::request wrote the row's key onto the host page's return state. The host's Enter(Restored) then missed and seated its top group. A page op whose return state was captured on another entry now leaves the page its own spot, as it already did while a surface still owned input. --- rust-modules/ui/src/containers/mod.rs | 5 +++++ rust-modules/ui/src/containers/tests.rs | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/rust-modules/ui/src/containers/mod.rs b/rust-modules/ui/src/containers/mod.rs index 67fce7ba25..4b797d0208 100644 --- a/rust-modules/ui/src/containers/mod.rs +++ b/rust-modules/ui/src/containers/mod.rs @@ -248,9 +248,14 @@ impl Navigation { /// routing performed here cannot drift. pub fn request(&mut self, op: NavOp, ret: ReturnState) -> Vec> { if self.moves_page(&op) { + let page = self.top_page().map(|e| e.id); let ret = if let Some(InputOwner::Entry(owner)) = self.modals.input_owner() { if let Some(e) = self.modals.entry_mut(owner) { e.ret = ret; } self.top_page().map(|e| e.ret.clone()).unwrap_or_default() + } else if ret.focus.is_some_and(|f| Some(f.entry) != page) { + // Captured on a surface that has closed since (a menu's pick parks its own + // `Dismiss` ahead of the page op it asks for): the page keeps its own spot. + self.top_page().map(|e| e.ret.clone()).unwrap_or_default() } else { ret }; self.tabs.stack.request(op, ret); return Vec::new(); diff --git a/rust-modules/ui/src/containers/tests.rs b/rust-modules/ui/src/containers/tests.rs index 21a8059afa..f5bb070361 100644 --- a/rust-modules/ui/src/containers/tests.rs +++ b/rust-modules/ui/src/containers/tests.rs @@ -3187,3 +3187,24 @@ fn the_owner_after_dismissals_is_the_page_once_the_surfaces_dismiss_is_parked() assert_eq!(d.nav.input_owner(), Some(InputOwner::Entry(home))); assert_eq!(d.input_owner_after_dismissals(), d.nav.input_owner(), "after the commit the two agree"); } + +/// **A page op parked behind a menu's `Dismiss` keeps the host's return spot.** Go to Movie in the +/// item hold menu parks the menu's `Dismiss`, then the app's `Push`, both captured on the menu's +/// row. The row's key used to reach the host's `ret`, so its `Enter(Restored)` missed and the page +/// ran to its top while the menu closed, and BACK came back to the top instead of the card. +#[test] +fn a_push_parked_behind_a_surfaces_dismiss_keeps_the_hosts_return_spot() { + let (mut d, mut rig, _) = booted(); + let home = d.nav.top_page().unwrap().id; + let card = FocusKey { entry: home, elem: 3 }; + d.set_focus(Some(card)); + let menu = open_modal(&mut d, &mut rig, Style::Compact, 16); + let row = FocusKey { entry: menu, elem: 1 }; + d.set_focus(Some(row)); + assert_eq!(d.nav.entry(home).unwrap().ret.focus, Some(card), "captured at the Present"); + d.request(MachineId::Nav, NavOp::Dismiss(menu)); + d.request(MachineId::Nav, NavOp::Push(FixtureArg::Page(20))); + d.frame(&mut rig, tick(32), vec![], vec![], &mut NoTap); + assert_eq!(d.nav.entry(home).unwrap().ret.focus, Some(card), + "the closing menu's row did not replace the host's return spot"); +} From c65c3414427f3dcb19f2499c0f74bedf1277f803 Mon Sep 17 00:00:00 2001 From: Tiago Pereira <1698241+tiper@users.noreply.github.com> Date: Thu, 19 Nov 2026 12:10:39 +0000 Subject: [PATCH 2/2] One fallback for a page op's return spot Both cases where the page keeps its own spot (a live surface took the captured one, or it was captured on a surface that has closed since) now share one fallback. --- rust-modules/ui/src/containers/mod.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/rust-modules/ui/src/containers/mod.rs b/rust-modules/ui/src/containers/mod.rs index 4b797d0208..655ba12288 100644 --- a/rust-modules/ui/src/containers/mod.rs +++ b/rust-modules/ui/src/containers/mod.rs @@ -248,15 +248,16 @@ impl Navigation { /// routing performed here cannot drift. pub fn request(&mut self, op: NavOp, ret: ReturnState) -> Vec> { if self.moves_page(&op) { - let page = self.top_page().map(|e| e.id); - let ret = if let Some(InputOwner::Entry(owner)) = self.modals.input_owner() { - if let Some(e) = self.modals.entry_mut(owner) { e.ret = ret; } - self.top_page().map(|e| e.ret.clone()).unwrap_or_default() - } else if ret.focus.is_some_and(|f| Some(f.entry) != page) { - // Captured on a surface that has closed since (a menu's pick parks its own - // `Dismiss` ahead of the page op it asks for): the page keeps its own spot. - self.top_page().map(|e| e.ret.clone()).unwrap_or_default() - } else { ret }; + // `ret` lands on the page only when it was captured there: a live surface keeps its + // own, and one captured on a surface that has closed since is dropped. + let ret = match self.modals.input_owner() { + Some(InputOwner::Entry(owner)) => { + if let Some(e) = self.modals.entry_mut(owner) { e.ret = ret; } + None + } + _ if ret.focus.is_some_and(|f| self.top_page().map(|e| e.id) != Some(f.entry)) => None, + _ => Some(ret), + }.unwrap_or_else(|| self.top_page().map(|e| e.ret.clone()).unwrap_or_default()); self.tabs.stack.request(op, ret); return Vec::new(); }