Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#4236·tamagui

[V2] Closed modal `Sheet` with `unmountChildrenWhenHidden` leaves an empty full-screen `Portal` wrapper on native

Author: dieguezguilleCreated Sep 28, 2026Updated Sep 28, 2026

Current Behavior

On native, a closed <Sheet modal unmountChildrenWhenHidden> unmounts its content but still renders <Portal>, and Portal.native always wraps its children in a full-screen View (position="absolute", inset={0}). Every closed modal sheet leaves one empty full-screen view in the portal host, so a screen that declares N sheets keeps N of them on top of the app. One screen in our app had 13–20.

Why it matters: on iOS 26 these wrappers broke UI automation in our app. XCUITest (Maestro) received only the 5 status-bar elements on a screen that rendered fine, and one wrapper reported accessibilityViewIsModal == YES even though nothing sets it. A/B on the same commit on the iOS 26.5 simulator: without the fix, our e2e suite fails after 1m37s; with it, the suite passes (1107 commands). Screenshot and hierarchy attached. We could not reproduce the collapse in the minimal app, but the empty wrappers themselves are deterministic.

Cause: in SheetImplementationCustom.tsx, modalContents is built even when mountedContents is null, and Portal.native.tsx renders the wrapper whatever children is. 3.0.0-beta.1479.1 has the same shape: a sheet that was opened and then closed still leaves one wrapper.

Expected Behavior

A closed modal sheet whose children are unmounted should mount nothing in the portal host.

We ship this fix as a pnpm patch. It only touches the native dist, it also passes the repro on 3.0.0-beta.1479.1, and our full iOS/Android/web e2e suites pass with it:

diff
-    const modalContents = (
+    const modalContents = mountedContents == null ? null : (
       <Portal stackZIndex={zIndex} {...portalProps}>

Alternatives: skip the wrapper in Portal.native when children is empty, or honor hidden on native.

Tamagui Version

markdown
2.7.7 (latest), unchanged on main @ 0eb99e3.
Also reproduced on 1.144.4 and 3.0.0-beta.1479.1.

Platform (Web, iOS, Android)

markdown
iOS and Android (shared code path). Web is not affected.

Reproduction

markdown
https://github.com/dieguezguille/tamagui-sheet-empty-portal-repro

One screen with 4 modal sheets, all with unmountChildrenWhenHidden.

pnpm install
pnpm test     # main: "Expected length: 0, Received length: 4"

git checkout with-fix && pnpm install
pnpm test     # passes

On device (pnpm expo run:ios --configuration Release): the Xcode view debugger
and `maestro hierarchy` both show 4 empty full-screen views at the root. They are gone with the fix.

System Info

markdown
macOS 27.0 (arm64), Node 24, pnpm 11.5.2, Xcode 27.0, iOS 26.5 simulator, maestro 2.10.0
expo 57.0.25, expo-router 57.0.23, react-native 0.86.3, react 19.2.3
tamagui / @tamagui/sheet / @tamagui/portal 2.7.7 (default portal path, no setup-teleport)

Source: tamagui/tamagui

View original on GitHubView discussion on GitHub