Skip to content

A sheet dismissed from a route pushed inside it closes the whole sheet on iOS - #8

Merged
janicduplessis merged 1 commit into
mainfrom
@janic/web-push-in-sheet
Nov 15, 2026
Merged

janicduplessis merged 1 commit into
mainfrom
@janic/web-push-in-sheet

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Nov 15, 2026 •

Copy link
Copy Markdown

Description

An app can push a route on the same stack after a sheet (navigationPresentation="modal"), so the push happens inside the sheet. The common case is a menu sheet whose rows open Stats or Settings, with a Back control that returns to the menu. iOS shows the route on the sheet's own UINavigationController, with the native back chevron. But once a route was pushed inside the sheet, swiping the sheet down did not close it; the sheet only moved to its smaller detent. Tapping the backdrop and the agent's back were refused the same way. ModalHost.refusesDismissal treats the sheet's own route as inactive while something is pushed over it, so it refused. Upstream has the same code.

On the web, upstream already keeps a pushed route inside its sheet (expo/exact@b564083f4, expo/exact@1f79f30e), so this PR leaves the web host alone.

Solution

The new NavigationHost.sheetDismissal(_:) dismisses from the sheet's own route while a route is pushed inside it, the way the Mac already does (BackMac.swift dismiss). It presses the sheet's Back control if the app named one, and otherwise goes back to the route beneath the sheet. Swipe-down, the backdrop tap and the agent's back all use it, so the whole sheet goes. If the app named a Back control that is disabled or missing, the dismissal is still refused.

sheetDismissal lives in ModalIOS.swift's NavigationHost extension. selectedRoute in BackIOS.swift is no longer private, for it. The contract docs get one table row (contract-for-agents.md), and the humans' guide now says iOS, like Android, closes the whole sheet on a drag down or a scrim tap.

Test plan

  • bun host/apple/build.mjs --test --ios --only ModalStackIOSTests on an iOS 27.0 simulator, including the new testDismissingASheetFromARoutePushedInsideItLeavesTheWholeSheet. All pass on the rebased branch. That test dismisses from the route pushed inside the sheet, then checks that the selected route is the one beneath the sheet and the background stack is unchanged.
  • Upstream's host/web/tests/sheet-detent.test.mjs covers the web side in Chrome, including a push inside a sheet. 9 pass.
  • Before the rebase, I built an app with a menu sheet that pushes Stats. On the iOS simulator, swiping the sheet down from Stats closed the whole sheet. I haven't repeated that check on the rebased branch.

@janicduplessis
janicduplessis marked this pull request as ready for review November 15, 2026 01:23
@janicduplessis
janicduplessis force-pushed the @janic/web-push-in-sheet branch from 6bc880c to 50b18c2 Compare November 15, 2026 02:26
@janicduplessis
janicduplessis changed the base branch from main to @janic/sync-upstream November 15, 2026 02:27
…t on iOS

Once a route was pushed inside a sheet, swiping the sheet down only moved it
to its smaller detent, and a tap behind it and the agent's back were refused:
ModalHost.refusesDismissal treats the sheet's own route as inactive while
something is pushed over it. NavigationHost.sheetDismissal goes back from the
sheet's own route, as the Mac does (BackMac.swift dismiss): it presses the
sheet's Back control if the app named one, and otherwise goes back to the
route beneath the sheet. If the named Back control is disabled or missing,
the dismissal is still refused.

Upstream's web host already keeps a pushed route inside its sheet
(b564083, 1f79f30), and its host/web/tests/sheet-detent.test.mjs covers it.
@janicduplessis
janicduplessis force-pushed the @janic/web-push-in-sheet branch from 50b18c2 to 89ba45c Compare November 15, 2026 02:51
@janicduplessis janicduplessis changed the title A route pushed inside a sheet stays in it on the web, and the sheet still dismisses on iOS A sheet dismissed from a route pushed inside it closes the whole sheet on iOS Nov 15, 2026
@janicduplessis

Copy link
Copy Markdown
Author

I rebased this onto @janic/sync-upstream (#10), which merges expo/exact main at a107143. This branch conflicted with that merge, so it would have stopped merging into main once the sync lands. The base is now @janic/sync-upstream, so the diff shows only this PR. Retarget it to main after the sync merges.

What changed in the rebase:

  • Web part dropped. Upstream's b564083 and 1f79f30 keep a pushed route inside its sheet (data-exact-in-sheet, sheetFrame), and upstream split host/web/navigation.js into host/web/navigation/*.js. navigation.js and neutral.css are upstream's. host/web/tests/sheet-push.test.mjs is removed too. It served only navigation.js, which is now a module of re-exports. It also asserted this PR's own sheet layout, which differs from upstream's. Upstream's host/web/tests/sheet-detent.test.mjs covers a push inside a sheet as upstream lays it out, and its 9 tests pass.
  • iOS part kept. Upstream's refusesDismissal still refuses a sheet's dismissal while a route is pushed inside it. sheetDismissal sits in ModalIOS.swift's NavigationHost extension. Upstream moved selectedRoute to BackIOS.swift, so that is where it loses private. routeIDs is already private(set) upstream, and goBack(from:to:) is already internal.
  • Docs. Upstream's contract-for-humans.md already has a paragraph on pushes inside a sheet, so the new paragraph is gone. Its Android sentence now reads "On iOS and Android". The contract-for-agents.md row stays.
  • The two commits are squashed into one, whose message describes the iOS fix.

bun host/apple/build.mjs --test --ios --only ModalStackIOSTests on an iOS 27.0 simulator passes, including testDismissingASheetFromARoutePushedInsideItLeavesTheWholeSheet. The description is updated to match the new diff.

@janicduplessis
janicduplessis changed the base branch from @janic/sync-upstream to main November 15, 2026 03:40
@janicduplessis
janicduplessis merged commit cf0e6f8 into main Nov 15, 2026
2 checks passed
ccheever added a commit to expo/exact that referenced this pull request Nov 15, 2026
Once a route was pushed inside a sheet, the sheet's own route was no
longer the selected one, and ModalHost refused every dismissal of an
inactive route: a swipe down only moved the sheet to its smaller detent,
and a tap behind it and the agent's dismissal did nothing.

NavigationHost.sheetBack now says how a sheet's dismissal goes back. With
the sheet's own route selected it is that route's Back, as before. With
routes pushed inside the sheet it is a history jump from the selected
route to the route beneath the sheet (goBack(from:to:)), as a pop of
several routes already is: the root's navigate with that location, else
the runner's own back to it. A disabled navigationBack control on the
selected route still refuses the dismissal. The sheet closes with what
was pushed inside it, as LLP 1008 "Presented routes" and LLP 1115.001
have it and as the painted hosts already do.

The test is from Janic Duplessis's fork (appandflow#8). The fork
pressed the sheet's named Back control instead; one press pops only the
top route while UIKit has already dismissed the sheet, so the jump does
not press it, as a pop of several routes does not.

Fixes #665.

Co-authored-by: Janic Duplessis <janicduplessis@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant