Skip to content

fix(ui): stop Screen padding by the status bar under a nav header - #744

Merged
islandbitcoin merged 4 commits into
mainfrom
eng-611/screen-top-inset
Sep 25, 2026
Merged

islandbitcoin merged 4 commits into
mainfrom
eng-611/screen-top-inset

Conversation

@islandbitcoin

@islandbitcoin islandbitcoin commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes ENG-611. Found on device while testing #743; reported by Jabari as "a large empty space at the top of the home screen ... it seems to be on all screens."

The bug

Every screen with a navigation header carries a status-bar-high band of dead space between the header and its first content. Home, Settings, everything that renders <Screen> under a header. Both platforms.

The top inset is applied twice:

  1. React Navigation's header already reserves it — @react-navigation/elements Header.tsx:80 computes headerStatusBarHeight and renders a spacer View of that height (:236).
  2. Screen then pads by it again: the wrapper is SafeAreaView with no edges prop, so all four edges default to additive, top included.

Introduced by #741 (2a7cad14b), which changed screen.tsx from SafeAreaView imported from react-native to the safe-area-context one. React Native's own is a plain View on Android (zero padding) and genuinely position-aware on iOS via UIKit — so both platforms were correct before. #742 (targetSdk 36) made it visible rather than latent by forcing edge-to-edge. Not in 0.7.2 — this is a 0.7.3 RC regression only.

The docblock was wrong, and that's how this got in

#741 added a comment asserting the wrapper "is position-aware: the native view pads only by the part of the window insets it actually overlaps ... screens with headers do not double-pad."

safe-area-context 5.6.2 does not work that way. It reads the nearest provider's insets verbatim and does no frame math against the view's own position — Android resolves findProvider() then getSafeAreaInsets(providerView); iOS reads _providerView.safeAreaInsets; the Fabric shadow node folds stateData.insets.top in unchanged. Our provider is the root SafeAreaProvider in app.tsx, which spans the window, so top is always the full status bar no matter how deep the screen sits. The docblock is replaced with what the library actually does, so this doesn't come back.

The fix

Drop the top edge when HeaderShownContext reports a header above us — the same signal the header itself uses to decide whether to reserve the status bar — and keep all four edges when there is none, where this wrapper is the only thing holding content clear of the status bar. The unsafe branch now renders View explicitly, since edges is not a valid View prop.

Measured on device

Same build, only this commit removed, on both phones against TEST:

before after delta
Pixel 8 Pro — Home greeting y=526 y=375 151px = status bar height
iPhone 13 Pro Max — "Send" y=358 y=311 47pt = status bar inset
iPhone 13 Pro Max — carousel y=402 y=355 47pt

Header icons (Pixel y=151, iPhone y=56) and tab bars (y=2758 / y=851) are unchanged on both, so only the duplicate inset went away. Settings shows the same improvement, confirming it is app-wide.

These numbers say nothing about the bottom edge — they measure where the tab bar sits, not the gap above it. See "Bottom edge" below.

Tests

__tests__/components/screen-header-inset.spec.tsx pins edges for both presets, with and without a header, plus the unsafe branch of each (both were rewritten to literal Views here and only the non-scrolling one had prior coverage, in screen-android.spec.tsx). Every case was mutation-checked rather than assumed: 4 of the 6 edges cases fail with this fix reverted, and both unsafe cases fail with the branch flipped.

The existing specs could not have caught the original bug: screen-android.spec.tsx only asserts the tree contains RNCSafeAreaView, and screen.spec.tsx renders under a mock fed initialMetrics with no notion of a header above the wrapper.

Full suite green — 1297, up from 1295 on the parent commit. tsc clean, eslint clean, prettier clean.

Bottom edge — same defect, not fixed here (ENG-612)

bottom stays in EDGES_BELOW_HEADER, and it has the identical double-pad problem from the same origin (#741): @react-navigation/bottom-tabs pads the tab bar by insets.bottom (BottomTabBar.tsx:86) and lays it out below the scene in normal flow (:283), so on every tab screen — Home, Map, Scan, Settings — this wrapper adds that inset a second time. Nothing in the app compensates; there are zero useBottomTabBarHeight / BottomTabBarHeightContext consumers.

It is deliberately out of scope because it is not a one-line change and cannot be closed without a device:

  • getTabBarHeight (BottomTabBar.tsx:89) returns a non-zero default for tabBarStyle: { display: "none" } — it only short-circuits on an explicit numeric height, and our bottomNavigatorStyle sets minHeight.
  • BottomTabBarHeightContext is seeded from that and updated only by the bar's onLayout, so whether it reads 0 on a hidden bar is unverified.
  • Two routes hide the bar that way — Chat → messages (root-navigator.tsx:885) and Scan (:921) — and both still need the bottom inset. app/screens/chat/messages.tsx:88 depends on it explicitly: useKeyboardPaddingStyle(insets.bottom) subtracts the inset Screen applies.

Filed as ENG-612 with the full reasoning, documented in the screen.tsx banner, and the spec previously named "keeps the side and bottom edges, which no header reserves" renamed to "...which the header does not reserve" so the suite stops implying the bottom is settled.

Dependency note

@react-navigation/elements moves from a transitive to a declared dependency at ^1.3.31 — the exact spec already resolved in yarn.lock, so yarn install --frozen-lockfile leaves the lockfile byte-identical. It was already in the tree via bottom-tabs and stack.

Unrelated thing worth knowing

npx react-native bundle --assets-dest android/app/src/main/res writes generated PNGs into that tracked directory and nothing gitignores them, so a local device build leaves ~28 untracked files that are easy to commit by accident. Not fixed here.

🤖 Generated with Claude Code

…G-611)

#741 swapped Screen's wrapper from React Native's SafeAreaView to
react-native-safe-area-context's and passed no `edges`, so all four edges
pad additively. React Navigation's header already reserves the status bar
(it renders a spacer of insets.top above its content), so every screen with
a header gained a second status-bar-high band of dead space beneath the
header.

The docblock added in #741 claimed the wrapper is position-aware and so
could not double-pad. That is not true of safe-area-context 5.x, which
reads the nearest provider's insets verbatim and does no frame math against
the view's own position — Android resolves findProvider() then
getSafeAreaInsets(providerView), iOS reads _providerView.safeAreaInsets,
and the Fabric shadow node folds stateData.insets.top in unchanged. Our
provider is the root SafeAreaProvider in app.tsx, which spans the window,
so `top` is always the full status bar however deep the screen sits. Both
platforms are affected; the docblock is corrected here.

Drop the top edge when HeaderShownContext says a header is shown above us
— the same signal the header itself uses to decide whether to reserve the
status bar — and keep all four when there is none, where this wrapper is
the only thing holding content clear.

Measured on device, both platforms, against the same build with only this
commit removed:
- Pixel 8 Pro: Home greeting y=526 -> y=375, a delta of 151px, exactly the
  status bar height. Header icons (y=151) and tab bar (y=2758) unchanged.
- iPhone 13 Pro Max: "Send" y=358 -> y=311 and the carousel y=402 -> y=355,
  a delta of 47pt, exactly the status bar inset. Header icon (y=56) and tab
  bar (y=851) unchanged.

The existing specs could not catch this: one asserts only that the tree
contains RNCSafeAreaView, the other renders under a mock fed initialMetrics
with no notion of a header above the wrapper. The new spec pins `edges` in
both presets and fails 4 of its 6 cases with this fix reverted.

@react-navigation/elements moves from a transitive to a declared dependency
at the spec already resolved in yarn.lock (^1.3.31); yarn install
--frozen-lockfile leaves the lockfile untouched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@linear

linear Bot commented Sep 25, 2026

Copy link
Copy Markdown

ENG-611

Dread and others added 3 commits September 25, 2026 11:29
Review fixes on ENG-611.

- The 37-line safe-area docblock had ended up as a JSDoc on
  `EDGES_BELOW_HEADER`, an array of three strings, because the constant was
  inserted between the comment and the function it was written for. Move it
  to a file-level banner above the imports and leave a one-line JSDoc on the
  constant. `ScreenWithoutScrolling` gets its blank line back.

- Both `unsafe` branches were rewritten to literal `View`s in this PR and
  neither was covered here; only the non-scrolling one had a check, in
  screen-android.spec.tsx. Add a case to the preset loop asserting no
  SafeAreaView is rendered, so a future edit that wires `edges` into the
  scrolling `unsafe` path cannot ship silently. Verified it fails for both
  presets with the branch mutated.

- The bottom edge has the same double-pad defect: a bottom tab bar pads
  itself by `insets.bottom` and sits below the scene in normal flow, so this
  wrapper adds it a second time on every tab screen. Not fixed here — the
  routes that hide the bar with `tabBarStyle: { display: "none" }` still need
  the inset and `BottomTabBarHeightContext` cannot be trusted to read 0 for
  them without a device. Filed as ENG-612; documented in the banner, and the
  "which no header reserves" spec renamed to "which the header does not
  reserve" so the suite stops implying the bottom is settled.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…onour edges

Review fixes for ENG-611.

The banner claimed HeaderShownContext is equivalent to "the header reserves
the status bar". It is not: with headerTransparent the header is rendered
absolutely and reserves nothing (stack CardStack's isFloatHeaderAbsolute,
bottom tabs' styles.absolute on the header) while the context is still true.
No route in the app sets it today, so nothing is broken now — but the banner
is otherwise exhaustive about this mechanism and gave no warning. Record the
exception in the banner and stop the useSafeAreaEdges docblock asserting the
equivalence as fact.

screen.spec.tsx's SafeAreaViewMock still modelled the pre-ENG-611 contract:
it ignored `edges` and padded all four sides unconditionally, so every
assertion in the file stayed green no matter what edges Screen passed —
including `edges={[]}`. Make the mock honour the prop, and add a spec that
renders under HeaderShownContext and asserts the top pad is actually 0 while
the bottom one survives. That spec fails against the old mock.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The banner told the next engineer to pass `unsafe` on a transparent-header
route. `unsafe` swaps the whole SafeAreaView for a bare View, so left, right
and bottom go with the top, and on an edge-to-edge window the content then
runs under the navigation bar — the defect this wrapper exists to prevent.
That is the same failure this PR indicts #741 for: a docblock prescribing
something the code does not support.

Point at what actually works (reinstate the top inset from
useSafeAreaInsets() on the route's own content) and warn off `unsafe`
explicitly. No API change: no route uses headerTransparent today, so adding
an `edges` override for a hypothetical caller would be speculative surface.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@islandbitcoin
islandbitcoin merged commit 62bc4c8 into main Sep 25, 2026
9 of 10 checks passed
@islandbitcoin
islandbitcoin deleted the eng-611/screen-top-inset branch September 25, 2026 19:22
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