Fix Android navigation bar transparency for Modal - #58491
Open
jasozh wants to merge 1 commit into
Open
Conversation
Summary: Fixes the issue described in [react#39018](react#39018), where it is currently impossible to draw a correct modal scrim on Android. The issue described the modal scrim not covering both the status bar and the navigation bar. While the status bar is now already covered, the navigation bar is not. ### Root Cause Modal currently has two Android props related to translucency: `statusBarTranslucent` and `navigationBarTranslucent`. Both options are essentially redundant on modern Android devices, as edge-to-edge mode in React Native has been enabled for all Android 15+ devices. Even with navigation bar translucency enabled, the 3-button navigation bar and 2-button gesture bar still have a semi-opaque contrast bar overlaid on top. The color is based on the current device theming: light mode shows black nav buttons with a semi-opaque white background, while dark mode shows white nav buttons with a semi-opqaue black background. This leads to an issue when a light mode app wants to open a semi-transparent dark modal scrim. Since the nav bar still has a semi-white background, the modal scrim looks off and not fully edge to edge. ### This PR Modify `ReactModalHostView` so that when Modal's `transparent` prop is set to true and `navigationBarTranslucent` is enabled, disable `isNavigationBarContrastEnforced`. This maintains the existing contract for `transparent` which assumes the Modal fills the entire view. Changelog: [Android][Fixed] Fix Android navigation bar transparency for Modal Differential Revision: D119589178
|
@jasozh has exported this pull request. If you are a Meta employee, you can view the originating Diff in D119589178. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Fixes the issue described in #39018, where it is currently impossible to draw a correct modal scrim on Android. The issue described the modal scrim not covering both the status bar and the navigation bar. While the status bar is now already covered, the navigation bar is not.
Root Cause
Modal currently has two Android props related to translucency:
statusBarTranslucentandnavigationBarTranslucent. Both options are essentially redundant on modern Android devices, as edge-to-edge mode in React Native has been enabled for all Android 15+ devices.Even with navigation bar translucency enabled, the 3-button navigation bar and 2-button gesture bar still have a semi-opaque contrast bar overlaid on top. The color is based on the current device theming: light mode shows black nav buttons with a semi-opaque white background, while dark mode shows white nav buttons with a semi-opqaue black background.
This leads to an issue when a light mode app wants to open a semi-transparent dark modal scrim. Since the nav bar still has a semi-white background, the modal scrim looks off and not fully edge to edge.
This PR
Modify
ReactModalHostViewso that when Modal'stransparentprop is set to true andnavigationBarTranslucentis enabled, disableisNavigationBarContrastEnforced. This maintains the existing contract fortransparentwhich assumes the Modal fills the entire view.Changelog: [Android][Fixed] Fix Android navigation bar transparency for Modal
Differential Revision: D119589178