Skip to content

fix(ios): present navigator sheets opened under a fullScreenModal - #1021

Open
maxlapides wants to merge 2 commits into
lodev09:mainfrom
maxlapides:mlapides/sheet-under-fullscreen-modal
Open

maxlapides wants to merge 2 commits into
lodev09:mainfrom
maxlapides:mlapides/sheet-under-fullscreen-modal

Conversation

@maxlapides

@maxlapides maxlapides commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On iOS, a sheet-navigator sheet never presents if its route opens while the navigator's base screen shows a react-native-screens fullScreenModal (for example, a deep link or a button inside the modal that navigates to a sheet route).

A full-screen presentation takes the views under it out of the window. The navigator renders its sheets beside the base screen, so a sheet mounted while the modal is up has no window:

  • TrueSheetView only registered with TrueSheetModule from didMoveToWindow, so dismiss() (and closing the route) rejected with No sheet found with tag N.
  • findPresentingViewController started from self.window.rootViewController, so auto-present never found a presenter and the sheet never appeared.
  • The route was left half-open (closing with no native sheet), so a back action through the sheet navigator (e.g. Expo Router's router.back()) was consumed by it, and the modal could no longer close that way. If the modal closed through its own stack instead, the sheet popped up late over the base screen.

This PR:

  • Registers the host with the module on mount instead of on window attach.
  • Adds presentationWindow: when the host has no window because a full-screen modal covers it, and that modal was presented by a stack the host isn't part of (react-native-screens keeps a presented screen's reactSuperview on its stack), the sheet presents in the modal's window, over the modal. This covers sheet-navigator sheets and sheets rendered beside the navigation tree (e.g. a root-level named sheet).
  • Leaves sheets inside the covered stack unchanged: an inline sheet on a screen behind a fullScreenModal still waits for its screen to come back, as the Deep Linking guide describes. present() there still rejects with "No presenting view controller found".
  • Adds a fullScreenModal repro screen to the bare example's sheet navigator (Sheet Navigator → Open Full Screen Modal → Open Details / Settings Sheet).

Android is unchanged.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Test Plan

iOS 27.2 simulator (iPhone 18 Pro), bare example, A/B against main:

  • main: Open Full Screen Modal → Open Details Sheet shows nothing. A back action through the sheet navigator throws Uncaught (in promise): Error: No sheet found with tag …, and the modal stays up. Closing the modal through its own stack makes the stuck Details sheet pop up over Home.
  • This branch: the Details sheet presents over the modal with its footer. Resize to 100%, the stacked Settings sheet (reanimated) over it, pop(), Go Back, and swipe-to-dismiss all work. The modal closes afterwards, and no stale sheet appears.
  • Inline sheets inside the covered stack (temporary probes, not committed): present() on a sheet in the base's Home screen while the modal is up still rejects. A sheet mounted there with initialDetentIndex waits, then presents once the modal closes. A named sheet rendered beside NavigationContainer presents over the modal.
  • Regressions: Test Screen → back (sheet hidden and re-presented by navigation), the root fullScreenModal (Open Modal) with its inline sheets, the main sheet after closing it, and the sheet navigator without a modal.
  • yarn typecheck, yarn test (175 passed), eslint, prettier, clang-format.

Screenshots / Videos

iOS 27.2 simulator, bare example. Some captures show a temporary "TMP Root Back" button (not committed) that calls the parent navigator's goBack(), the way Expo Router's router.back() does. The repro code is in a comment below.

Open Details Sheet from the modal

On main, nothing presents. With the fix, the sheet presents over the modal.

Before (main)

before-after-tap-details

After

after-details-over-modal

Go back through the sheet navigator

On main, this throws No sheet found with tag … and the modal stays up. With the fix, the sheet dismisses and the modal is usable again.

Before (main)

before-root-back

After

after-details-dismissed

Close the modal

On main, the stuck Details sheet pops up over Home. With the fix, Home has no stale sheet.

Before (main)

before-after-stack-close

After

after-modal-closed

Recordings

Before (main): Open Details Sheet does nothing, so the modal stays up with no sheet. At about 0:16, Close Modal closes the modal and the stuck Details sheet pops up over Home. Taps aren't shown in the recordings.

before-head.mp4

Before (main): Open Details Sheet does nothing. TMP Root Back throws No sheet found with tag … (about 0:22) and the modal stays up, even after a second tap. At about 0:35, Close Modal closes the modal and the stuck Details sheet pops up over Home.

before-root-back.mp4

After: Details presents over the modal. Then resize, a stacked Settings sheet, pop, Go Back, swipe-to-dismiss Settings, and Close Modal, which leaves no stale sheet on Home.

after-fix.mp4

Checklist

  • I tested on iOS
  • I tested on Android
  • I tested on Web
  • I updated the documentation (if needed)
  • I added a changelog entry (if needed)

A full-screen modal takes the views under it out of the window. A
sheet-navigator sheet is hosted beside its base screen, so a sheet route
opened while the base shows a fullScreenModal never registered with the
module or found a presenter: it never appeared, dismiss() rejected with
SHEET_NOT_FOUND, and the half-open route swallowed the modal's back
action.

Register hosts on mount, and when the modal covering a windowless host
was presented by a stack the host isn't part of, present in that modal's
window. Sheets inside the covered stack still wait for their screen. The
bare example's sheet navigator gets a fullScreenModal repro screen.
@vercel

vercel Bot commented Nov 11, 2026

Copy link
Copy Markdown

@maxlapides is attempting to deploy a commit to the lodev09 Team on Vercel.

A member of the Team first needs to authorize it.

@maxlapides

Copy link
Copy Markdown
Contributor Author

Repro code behind the screenshots and recordings in the description. It's the bare example's sheet navigator (example/bare/src/navigators/SheetNavigator.tsx), where FullScreenModal is a fullScreenModal screen in the navigator's base stack.

The committed version is the same, without the TMP Root Back button:

// HomeScreen (the navigator's base screen)
<Button
  text="Open Full Screen Modal"
  onPress={() => navigation.navigate('SheetHomeStack', { screen: 'FullScreenModal' })}
/>

const FullScreenModalScreen = () => {
  const navigation = useTrueSheetNavigation<AppStackParamList & SheetStackParamList>();

  return (
    <View style={styles.content}>
      <View style={styles.heading}>
        <Text style={styles.title}>Full Screen Modal</Text>
        <Text style={styles.subtitle}>
          A fullScreenModal inside the sheet navigator's base screen. Sheets opened from here
          present over it.
        </Text>
      </View>
      <Button text="Open Details Sheet" onPress={() => navigation.navigate('Details')} />
      <Button text="Open Settings Sheet" onPress={() => navigation.navigate('Settings')} />
      <Button text="Close Modal" onPress={() => navigation.goBack()} />
      {/* Temporary, not committed: goes back through the sheet navigator, like Expo Router's router.back() */}
      <Button text="TMP Root Back" onPress={() => navigation.getParent()?.goBack()} />
    </View>
  );
};

// SheetHomeNavigator (the base screen's stack)
<SheetHomeStack.Navigator>
  <SheetHomeStack.Screen name="Home" component={HomeScreen} />
  <SheetHomeStack.Screen name="Test" component={TestScreenWrapper} />
  <SheetHomeStack.Screen
    name="FullScreenModal"
    component={FullScreenModalScreen}
    options={{ presentation: 'fullScreenModal', headerShown: false }}
  />
</SheetHomeStack.Navigator>

Steps: Sheet Navigator → Open Full Screen Modal → Open Details Sheet, then TMP Root Back or Close Modal.

Temporary probes for the inline-sheet checks in the Test Plan (not committed)
// HomeScreen, inside the stack the modal covers
<TrueSheet name="tmp-home-inline" detents={['auto']}>
  <Text>TMP Home Inline (present)</Text>
</TrueSheet>
{tmpHomeAuto && (
  <TrueSheet initialDetentIndex={0} detents={['auto']}>
    <Text>TMP Home Inline (auto)</Text>
  </TrueSheet>
)}

// App.tsx, beside the navigation tree
<NavigationContainer>
  <RootNavigator />
</NavigationContainer>
<TrueSheet name="tmp-root" detents={['auto']}>
  <Text>TMP Root Sheet</Text>
</TrueSheet>

// FullScreenModalScreen
<Button
  text="TMP Present Home Inline" // rejects: "No presenting view controller found"
  onPress={() => TrueSheet.present('tmp-home-inline').then(onPresented, onRejected)}
/>
<Button
  text="TMP Mount Home Auto" // waits, then presents once the modal closes
  onPress={() => setTmpHomeAuto(true)}
/>
<Button
  text="TMP Present Root" // presents over the modal
  onPress={() => TrueSheet.present('tmp-root').then(onPresented, onRejected)}
/>

@maxlapides
maxlapides marked this pull request as ready for review November 11, 2026 03:27

This branch has not been deployed

No deployments
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