Skip to content

Handle edge-to-edge when it's not enabled by gradle property#56055

Closed
zoontek wants to merge 13 commits intofacebook:mainfrom
zoontek:handle-edge-to-edge-when-not-property
Closed

Handle edge-to-edge when it's not enabled by gradle property#56055
zoontek wants to merge 13 commits intofacebook:mainfrom
zoontek:handle-edge-to-edge-when-not-property

Conversation

@zoontek
Copy link
Copy Markdown
Contributor

@zoontek zoontek commented Mar 11, 2026

Summary:

On Android 15 (API 35), edge-to-edge is enforced by default unless the app explicitly opts out via windowOptOutEdgeToEdgeEnforcement. On Android 16+, it's always enforced regardless.

Previously, edge-to-edge behavior was only driven by the edgeToEdgeEnabled gradle property, meaning apps on Android 15+ could be in edge-to-edge mode without React Native being aware of it, leading to incorrect insets / layout behavior.

This PR introduces isEdgeToEdge, a computed value that accounts for the OS-level enforcement in addition to the gradle flag, and replaces most usages of isEdgeToEdgeFeatureFlagOn with it. A new initEdgeToEdge(context, flag) function replaces setEdgeToEdgeFeatureFlagOn() and reads the theme attribute to detect opt-out on API 35.

Changelog:

[ANDROID] [FIXED] - Handle edge-to-edge when it's not enabled by the edgeToEdgeEnabled gradle property but enforced by the OS (Android 15+)

Test Plan:

  • Verify on Android 15 device/emulator without edgeToEdgeEnabled = true: isEdgeToEdge should be true (unless opted out via theme attribute).
  • Verify on Android 16+ device/emulator: isEdgeToEdge should always be true.
  • Verify on Android 14 and below without the flag: isEdgeToEdge should be false.
  • Verify with edgeToEdgeEnabled = true: behavior unchanged, isEdgeToEdge is true on all API levels.

@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 Mar 11, 2026
@facebook-github-bot facebook-github-bot added p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Mar 11, 2026
zoontek added a commit to zoontek/react-native that referenced this pull request Mar 11, 2026
@zoontek zoontek changed the title Handle edge-to-edge when it's not enabled by the edgeToEdgeEnabled gradle property Handle edge-to-edge when it's not enabled by gradle property Mar 11, 2026
zoontek added a commit to zoontek/react-native that referenced this pull request Mar 11, 2026
@zoontek zoontek force-pushed the handle-edge-to-edge-when-not-property branch from 27a6185 to 6c7846d Compare March 11, 2026 14:03
zoontek added a commit to zoontek/react-native that referenced this pull request Mar 11, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 11, 2026

@alanleedev has imported this pull request. If you are a Meta employee, you can view this in D100437440.

Comment thread packages/react-native/ReactAndroid/api/ReactAndroid.api Outdated
Comment thread packages/react-native/ReactAndroid/api/ReactAndroid.api
@zoontek zoontek force-pushed the handle-edge-to-edge-when-not-property branch from deafc34 to 01d0e4c Compare April 14, 2026 08:51
Comment thread packages/react-native/ReactAndroid/api/ReactAndroid.api Outdated
Comment on lines +61 to +62
val attributes = intArrayOf(AndroidVersion.ATTR_WINDOW_OPT_OUT_EDGE_TO_EDGE_ENFORCEMENT)
val typedArray = context.theme.obtainStyledAttributes(attributes)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be an issue when the context passed in is Application context and windowOptOutEdgeToEdgeEnforcement is set on the Activity. We may incorrectly decide there is no opt-out attribute set.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think you missed adding initEdgeToEdge() in ReactActivityDelegate. If this is fixed then initEdgeToEdge() is called first from ReactNativeApplicationEntryPoint (with the Application context) and then again from ReactActivityDelegate (with the Activity context). There may be some edge cases but it may still work mostly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alanleedev Fixed in acacab6. It even allows us to remove the public attribute on initEdgeToEdge

Copy link
Copy Markdown
Contributor Author

@zoontek zoontek Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cortinico
Copy link
Copy Markdown
Contributor

@alanleedev this can be re-imported imho

@meta-codesync meta-codesync bot closed this in c2280e3 Apr 16, 2026
@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @zoontek in c2280e3

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Apr 16, 2026
@zoontek zoontek deleted the handle-edge-to-edge-when-not-property branch April 16, 2026 16:54
zoontek added a commit to zoontek/react-native that referenced this pull request Apr 16, 2026
# Conflicts:
#	packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/WindowUtil.kt
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. Merged This PR has been merged. p: Expo Partner: Expo Partner 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.

5 participants