Skip to content

fix(mobile): keep the reader's header out of the status bar - #832

Merged
huichen merged 1 commit into
mainfrom
fix/preview-safe-area
Sep 25, 2026
Merged

huichen merged 1 commit into
mainfrom
fix/preview-safe-area

Conversation

@huichen

@huichen huichen commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

The file reader's header on Android starts at y = 0 while the system keeps drawing its status bar over the top of the screen, so the header's controls sit inside the status bar's hit area — tapping the "…" button pulls down the notification shade instead of opening the menu.

Measured on the reporting device (723×1600 screenshot of a 1080×2400 / 3x phone, so 1dp ≈ 2px):

row (dp) what
0–24 status bar: clock at 9–26dp, drawn over the app
0–60.5 the reader's header (its minHeight: 60), border at 60.5dp
28–37.5 header title/buttons, centred at ~32dp

So the header got no top inset at all. The SafeAreaView that was supposed to provide it cannot work here: it resolves insets by walking native ancestors up to the app's SafeAreaProvider, and a Modal is its own native window — nothing inside it descends from that provider, so it found none and applied nothing (harmless on iOS, where the reader is a pageSheet the system already places below the status bar).

Change

  • Read the inset from the SafeAreaProvider context (as every other Modal surface in the app does, via DialogSurface) and pad the reader's own surface by it on Android.
  • Set statusBarTranslucent on the reader's Modal so that "the reader is under the status bar" is deliberate on every Android device, instead of depending on how the system happens to lay that window out (WindowCompat.setDecorFitsSystemWindows(true) on the modal window is a no-op once edge-to-edge is enforced, and RN's fitsSystemWindows fallback on the modal's content view no longer pads).
  • Only the top edge is applied: statusBarTranslucent extends the reader under the status bar alone, the other edges are still laid out by the window.
  • iOS is unchanged (no inset: the sheet already clears the status bar, the context's window inset would only open a gap above the header).

Verification

  • npx jest --runInBand: 126 suites / 2003 tests pass.
  • npm run typecheck, eslint src/features/chat: clean.
  • New assertion in fileActionSurfaces.test.ts pins both halves (the modal is status-bar translucent, the surface is padded by the context inset on Android and not on iOS); falsified it by removing the padding and confirming it fails.
  • Not verifiable in the screenshot harness: react-native-web reads its insets from CSS env(safe-area-inset-*), which is 0 in desktop Chrome, so the harness renders identically before and after.
  • Please re-check on the phone: the header's three controls should now sit below the status bar.

Related, not touched here: ActionMenu and ModelSelectorSheet also wrap a Modal in the same SafeAreaView, so their bottom inset resolves to nothing on Android too.

On Android a Modal's window is laid out from the top of the screen and the
system draws its status bar over it. The reader's header therefore started at
y = 0, so the overflow button sat inside the status bar's hit area: taps there
pulled the notification shade down instead of opening the menu.

The `SafeAreaView` meant to prevent this cannot work inside a Modal — it
resolves insets by walking *native* ancestors up to the app's
`SafeAreaProvider`, and a Modal is a separate native window, so it found no
provider and applied nothing. Measured on the reporting device: the header
occupied rows 0-60dp with the status bar drawn over its top half.

Read the inset from the provider context instead, and make the geometry
deliberate with `statusBarTranslucent` so the reader extends under the status
bar on every Android device rather than only where the window happens to end
up that way. Only the top edge is ours: the other edges stay the window's.
iOS is unchanged — its reader is a `pageSheet`, which the system already
places below the status bar.
@huichen
huichen enabled auto-merge (squash) September 25, 2026 11:30
@huichen
huichen merged commit f776d41 into main Sep 25, 2026
12 checks passed
@huichen
huichen deleted the fix/preview-safe-area branch September 25, 2026 11:33
huichen added a commit that referenced this pull request Sep 25, 2026
#832 padded the reader's surface by the status-bar inset, but the header did
not move: Yoga positions an `absoluteFill` child from its parent's *border*
edge and sizes it to the border box, so a parent's padding never reaches one.
The layers are absoluteFill, so that padding was a no-op and the header stayed
under the status bar.

Verified against yoga-layout 3.2.1 with this component's structure: an
absolute child of a box padded by 30 kept `top = 0` and its full height, and
its header landed at screen y = 0 — reproducing the reported overlap — while
the same tree with a flex wrapper inside the padding put the header at y = 30.

Give the padded surface one normal flex child (`previewStack`) and hang the
layers off that, so the inset actually moves the documents. Everything inside
a layer keeps its own coordinate space, so the measured header height that
positions the overflow menu is still correct.
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