-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android only] StatusBar automatically becomes "light-content" every time a RN Modal is opened #34350
Comments
I have tried to reproduce it on my Samsung device but it's not reproducible. seems to be device specific bug. |
for work-around refer this #7474 (comment) |
@dakshbhardwaj We can reproduce this issue on Samsung Galaxy Note 10 plus. Which phone are you testing on? |
I am using Samsung galaxy tab a7 |
@sudharsanvishnu this workaround doesn't work. After disabling the status bar in |
can reprodue on all models (google pixel) emulator |
have you tried after syncing gradle
|
@sudharsanvishnu it hasn't made any difference. If you've got a minute, check out the following test example https://github.com/garkuwa/RN_statusbar_test/tree/main/AwesomeTSProject |
I'm experiencing the same issue with Google Pixel Emulator. |
Seeing the problem on Android v12 (Samsung S20, Platform Version 31). |
also experiencing this on Pixel 5 emulator (API 33) and a physical Pixel 6 Pro device but in reverse. I have set
|
Shot in the dark, but we were running into this same issue. I think it's caused by the fact that the react-native/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java Lines 193 to 204 in c4f9556
However, the modal host tries to read an untouched react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java Lines 326 to 336 in c4f9556
We added a manual override to the root activity to set that override fun onResume() {
super.onResume()
if (VERSION.SDK_INT >= VERSION_CODES.M) {
val newSystemUiVisibility = if (isInDarkMode) {
// Remove light status bar flag in dark mode
window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
} else {
// Add light status bar flag in light mode
window.decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
}
window.decorView.systemUiVisibility = newSystemUiVisibility
}
}
} |
Summary: As identified in #34350, modals do not honor the system's status bar colors because they may not be set by the deprecated `systemUiVisibility` flags. Unless `android:windowLightStatusBar` is set to true, the default flag is a zero-integer (a.k.a. "dark mode", where the icons show as white). Since the `StatusBar` component is using the new `setSystemBarsAppearance` API, the ModalHost should also infer its status bar settings from the same API. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Android] [Fixed] - Fixed an issue on Android API 31+ where modals would turn status bar icons white by default Pull Request resolved: #34899 Test Plan: - On a screen with the `StatusBar` bar style set to `dark-content`, the modal also uses white icons - On a screen with the `StatusBar` bar style set to `light-content`, the modal also uses black icons ### Preview Here, I change the `barStyle` from `light-content` to `dark-content` and demonstrate that the proper attributes are retained. The "Before" is a recording from `main` and the "After" is this branch. Notice how in "Before", the status bar is always turning the icons white when the modal opens. |Before|After| |-|-| |![ezgif-5-586e81991d](https://user-images.githubusercontent.com/10366495/194954666-71f69bd6-c02a-4725-9562-e1f5fcfdeddf.gif)|![ezgif-5-b212d7bb01](https://user-images.githubusercontent.com/10366495/194954244-9c205821-1d7f-4630-861b-f5dbe207f7cd.gif)| ## Other considerations There's some argument towards removing this check entirely--the status bar appearance should be derived from the theming and/or the parent activity's settings, thereby removing the need to apply separate styling Reviewed By: lunaleaps Differential Revision: D40243122 Pulled By: lunaleaps fbshipit-source-id: ffa56c7d6a1906f89658f95a12f6bf1cefd5be8e
Should be fixed by #34899 |
cheers @Abbondanzo |
Still have the issue in 0.70.6 |
The fix made it out in the first release candidate of 0.71.0, so 0.70.6 will still have that issue |
@Abbondanzo Facing this issue in 0.71.1 & 0.71.2
|
Summary: As identified in facebook#34350, modals do not honor the system's status bar colors because they may not be set by the deprecated `systemUiVisibility` flags. Unless `android:windowLightStatusBar` is set to true, the default flag is a zero-integer (a.k.a. "dark mode", where the icons show as white). Since the `StatusBar` component is using the new `setSystemBarsAppearance` API, the ModalHost should also infer its status bar settings from the same API. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Android] [Fixed] - Fixed an issue on Android API 31+ where modals would turn status bar icons white by default Pull Request resolved: facebook#34899 Test Plan: - On a screen with the `StatusBar` bar style set to `dark-content`, the modal also uses white icons - On a screen with the `StatusBar` bar style set to `light-content`, the modal also uses black icons ### Preview Here, I change the `barStyle` from `light-content` to `dark-content` and demonstrate that the proper attributes are retained. The "Before" is a recording from `main` and the "After" is this branch. Notice how in "Before", the status bar is always turning the icons white when the modal opens. |Before|After| |-|-| |![ezgif-5-586e81991d](https://user-images.githubusercontent.com/10366495/194954666-71f69bd6-c02a-4725-9562-e1f5fcfdeddf.gif)|![ezgif-5-b212d7bb01](https://user-images.githubusercontent.com/10366495/194954244-9c205821-1d7f-4630-861b-f5dbe207f7cd.gif)| ## Other considerations There's some argument towards removing this check entirely--the status bar appearance should be derived from the theming and/or the parent activity's settings, thereby removing the need to apply separate styling Reviewed By: lunaleaps Differential Revision: D40243122 Pulled By: lunaleaps fbshipit-source-id: ffa56c7d6a1906f89658f95a12f6bf1cefd5be8e
@Abbondanzo I'm seeing a related issue where the icons in the status bar are always black, and not respecting I think this is related to your fix in 34899, specifically this line: Line 335 in 0295771
If the status bar goes from black -> white, we need to call |
A reversal of bugs! In this case, the bitmask is wrong. Great catch! I'll cook up a PR tomorrow morning but in essence we should be grabbing the unmatched bits and writing them over for the dialog's window. It would look something like this: int activityAppearance = ((Activity) context).getWindow().getInsetsController().getSystemBarsAppearance();
int dialogAppearance = mDialog.getWindow().getInsetsController().getSystemBarsAppearance();
// Only write over each of the bits that do not match
int bitmask = activityAppearance ^ dialogAppearance;
mDialog.getWindow().getInsetsController().setSystemBarsAppearance(activityAppearance, bitmask); In the current implementation, if the activity has cleared the flag but the dialog creates windows that default to having the flag set, the activity's appearance values for each of those flags does not actually get set. I'll give that a try in the morning and file a new PR. I am curious why a bitmask of 0 is changing anything, however. This behavior is not very well documented, but intuition tells me that a mask of 0 is just a no-op. Even if a mask of 0 means every flag and you have light content on the backing activity (the flag is cleared), then applying 0 to every flag should keep the foreground icons white. Likewise, if the status bar flag is set then the mask and appearance values should also set. This means black->black and white->white. Are you perhaps applying any dialog styles in a theme somewhere and this is interfering? Or is this just the case where you change your status bar from |
@Abbondanzo thanks for the prompt reply, I'll keep an eye out for the next release with the fix!
Yeah good point, and it's why I'm not entirely convinced this will fix my specific issue but I'm hoping it'll narrow down the cause for the behaviour I'm seeing. I couldn't find anywhere else in the RN code that was setting the system bar's appearance (the In my application I'm just setting |
I've been trying to replicate this bug but (fortunately) haven't had any luck in doing so. I've got a small snack set up here to toggle the status bar before opening a modal: https://snack.expo.dev/@abbondanzo/status-bar-tester. Could you share a code snippet or snack that's causing the issue for you? I'd like to guarantee that the fix will actually solve your issue and detail the exact cause in the pull request. |
… modals (#40979) Summary: The current ReactModalHostView implementation incorrectly applies system bar appearances by providing the wrong mask to the `setSystemBarsAppearance` method invocation. Per [this issue comment](#34350 (comment)), jaydonlau correctly identified that when the status bar is set to `light-content` (light icons, dark background), the function is called with both a `0` appearance and `0` mask, which should instead be provided with the `APPEARANCE_LIGHT_STATUS_BARS` mask. The first pass at this PR attempted to pull out the entire appearance from the activity, compare it against the dialog's appearance, and only use a mask of differing bits (see the `appearanceMask` variable). However, if the `android:windowLightStatusBar` attribute is ever set to true, this does not impact the appearance of the status bar but rather the system UI visibility. As a result, the derived mask from system bars appearance would be 0 since both the activity and dialog would have appearances of 0. Rather than try and "future-proof" this implementation for other uses of system bar appearance, this change is directed only at updating the `APPEARANCE_LIGHT_STATUS_BARS` bit in the dialog's system bar appearance. The only other native code that touches status bars is the `StatusBarModule` and that only touches this flag. This is a follow-up to #34899. ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [ANDROID] [FIXED] - Fixed an issue where the status bar colors would not match when opening modals Pull Request resolved: #40979 Test Plan: First test: - Replace the `RNTesterAppShared` implementation with the implementation from [this Expo snack](https://snack.expo.dev/abbondanzo/status-bar-tester) - Toggle the status bar to show dark icons, open the modal and ensure that dark icons are displayed - Toggle the status bar to show light icons, open the modal and ensure that light icons are displayed Second test: - Set the `android:windowLightStatusBar` attribute to true in the `AppTheme` - Follow the steps from the First test above, guaranteeing that status bar appearance overrides the theme Reviewed By: NickGerleman Differential Revision: D50329714 Pulled By: luluwu2032 fbshipit-source-id: 26ecaca05f8e00a52e13767e468b552ac167fc98
Hi, this issue also surfaces on the iOS 17. "expo": "^49.0.0", I tested it both in a simulator and on a device. The font style of the StatusBar switches to the dark mode after the 'Save Password' modal is discarded. |
We're also having problems with this issue in our date-picker library web-ridge/react-native-paper-dates#363 |
@Abbondanzo strange it does not happen in your snack |
… modals (facebook#40979) Summary: The current ReactModalHostView implementation incorrectly applies system bar appearances by providing the wrong mask to the `setSystemBarsAppearance` method invocation. Per [this issue comment](facebook#34350 (comment)), jaydonlau correctly identified that when the status bar is set to `light-content` (light icons, dark background), the function is called with both a `0` appearance and `0` mask, which should instead be provided with the `APPEARANCE_LIGHT_STATUS_BARS` mask. The first pass at this PR attempted to pull out the entire appearance from the activity, compare it against the dialog's appearance, and only use a mask of differing bits (see the `appearanceMask` variable). However, if the `android:windowLightStatusBar` attribute is ever set to true, this does not impact the appearance of the status bar but rather the system UI visibility. As a result, the derived mask from system bars appearance would be 0 since both the activity and dialog would have appearances of 0. Rather than try and "future-proof" this implementation for other uses of system bar appearance, this change is directed only at updating the `APPEARANCE_LIGHT_STATUS_BARS` bit in the dialog's system bar appearance. The only other native code that touches status bars is the `StatusBarModule` and that only touches this flag. This is a follow-up to facebook#34899. ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [ANDROID] [FIXED] - Fixed an issue where the status bar colors would not match when opening modals Pull Request resolved: facebook#40979 Test Plan: First test: - Replace the `RNTesterAppShared` implementation with the implementation from [this Expo snack](https://snack.expo.dev/abbondanzo/status-bar-tester) - Toggle the status bar to show dark icons, open the modal and ensure that dark icons are displayed - Toggle the status bar to show light icons, open the modal and ensure that light icons are displayed Second test: - Set the `android:windowLightStatusBar` attribute to true in the `AppTheme` - Follow the steps from the First test above, guaranteeing that status bar appearance overrides the theme Reviewed By: NickGerleman Differential Revision: D50329714 Pulled By: luluwu2032 fbshipit-source-id: 26ecaca05f8e00a52e13767e468b552ac167fc98
I know that this is old thread, but It also happens on RN 0.73.6. After analysis, it looks like this is a problem with mask as @Abbondanzo mentioned. The problem only affects Android version >= 12. To avoid modifying the native code (AND not building the RN locally) until real fix, just add in
or when we want to have icons in white color in the model
However, it is then possible to have color problems on SplashScreen. The rest of the colors after the modals can be quietly set through the |
I am facing the same issue on Android after upgrading to RN 0.71.19. This issue was not there in 0.68.7. |
Description
I've created a very basic test project using native cli
npx react-native init AwesomeTSProject --template react-native-template-typescriptD
, and added a simple component with RN Modal like here https://reactnative.dev/docs/modal. Every time I click "Show Modal", the status bar becomes light, and I can't change it to dark even by settingbarStyle="dark-content"
forStatusBar
. When the modal is closed, the status bar becomes dark again. The issue is reproducible only on Android, which in my case is Pixel 4a.Version
0.69.3
Output of
npx react-native info
info Fetching system and libraries information...
System:
OS: macOS 12.4
CPU: (10) x64 Apple M1 Pro
Memory: 38.39 MB / 32.00 GB
Shell: 3.2.57 - /bin/sh
Binaries:
Node: 16.13.1 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.1.2 - /usr/local/bin/npm
Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
API Levels: 28, 29, 30, 31, 32
Build Tools: 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0
System Images: android-30 | Google APIs ARM 64 v8a, android-32 | Google APIs ARM 64 v8a, android-32 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2021.1 AI-211.7628.21.2111.8139111
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
Java: 11.0.12 - /opt/homebrew/opt/openjdk@11/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.0.0 => 18.0.0
react-native: 0.69.3 => 0.69.3
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Steps to reproduce
npx react-native init AwesomeTSProject --template react-native-template-typescriptD
Snack, code example, screenshot, or link to a repository
The text was updated successfully, but these errors were encountered: