Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions rust-modules/ui/src/containers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,16 @@ impl<H: Host> Navigation<H> {
/// routing performed here cannot drift.
pub fn request(&mut self, op: NavOp<H::Arg>, ret: ReturnState<H::Elem, H::Memory>) -> Vec<Life<H>> {
if self.moves_page(&op) {
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 { 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; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same hole one level up: with two surfaces stacked, a Dismiss of the upper one parked ahead of a page op leaves the lower surface as input owner, and this still writes the closed surface's row onto it. i didn't find a product path that stacks a menu on a panel and pushes from it, so not blocking, but the guard on line 258 could cover both arms: pick the target entry first (owning surface, else top page) and take ret only when ret.focus is None or names that entry.

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();
}
Expand Down
21 changes: 21 additions & 0 deletions rust-modules/ui/src/containers/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Loading