Skip to content

Preserve Android Modal layout flags when syncing system UI - #60257

Open
fairysword wants to merge 1 commit into
react:mainfrom
fairysword:fix/modal-dialog-layout-flags
Open

fairysword wants to merge 1 commit into
react:mainfrom
fairysword:fix/modal-dialog-layout-flags

Conversation

@fairysword

@fairysword fairysword commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

On API 30 and below, ReactModalHostView.updateSystemAppearance() synchronizes the Dialog with the Activity by assigning the Activity's decorView.systemUiVisibility to the Dialog's. Besides appearance and visibility flags, that value contains SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN and SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, which WindowCompat.setDecorFitsSystemWindows uses below API 30 to implement edge-to-edge. Right after show(), the Dialog's layout therefore follows the Activity's configuration instead of the Modal's props:

  • A Modal with both bars translucent, shown over an Activity that is not edge-to-edge, loses its layout flags, and its content is laid out within both bars.
  • A Modal with only statusBarTranslucent, shown over an Activity that sets these flags itself (for example through WindowCompat without the React Native edge-to-edge flag), inherits them and its content extends behind the opaque navigation bar.

The Modal's own flags come back the next time showOrUpdate() calls updateProperties(). In practice, that is the onHostResume() that ReactContext.addLifecycleEventListener posts when the host view attaches while the app is resumed. The steady state is therefore correct, but right after the Modal opens its content is briefly laid out with the wrong bounds.

This change keeps the three layout flags from the Dialog's current value and still copies every other flag from the Activity, so the status bar and navigation bar appearance and visibility keep following the Activity as before.

On its own, this change is not visible in the first case, because the initial Modal size currently excludes both bars anyway, so the transient size matches it. It becomes visible together with #60258, which computes the correct initial size: without this change, the root goes 780 → 704 → 780 dp on API 28 with both bars translucent.

Changelog:

[ANDROID] [FIXED] - Keep a Modal's own edge-to-edge layout flags when syncing system bar appearance from the Activity on API 30 and below

Test Plan:

Unit tests

./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest \
  --tests com.facebook.react.views.modal.ReactModalHostViewTest

ReactModalHostViewTest runs updateSystemAppearance() on API 28 and 30 and checks that:

  • the Dialog keeps its layout flags when the Activity has none;
  • the Dialog does not inherit the Activity's layout flags;
  • appearance and visibility flags are still copied from the Activity.

Physical device

Venus e5, API 28, both bars translucent, Activity not edge-to-edge. Root heights in dp from onLayout:

Build Root height
Before 704 → 780
With #60258 only 780 → 704 → 780
With #60258 and this change 780

The second case in the summary follows from the same code path and was not recorded on a device.

Video

Left to right: before, with #60258 only, and with both changes. Same device and static content, entrance animation disabled in all three builds, clips aligned to the first frame of the backdrop and slowed uniformly to 0.1×. In the right-hand clip, the top edge of the sheet does not move after it appears.

api28-venus-both-bars-translucent-3way.mp4

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 24, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 24, 2026
@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at 2d12fc569360.

ios: no capture

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

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant