Stop syncing Modal system bars from Activity on Android#56916
Conversation
|
@alanleedev has imported this pull request. If you are a Meta employee, you can view this in D106013785. |
|
Had a short chat with @zoontek.
|
|
@cortinico we discussed this with @alanleedev, and I'm not sure there's an easy solution here. Since teams at Meta handle navigation bar styling in different ways across projects, we could introduce an opt-in flag to bypass this code (that is planned for removal). Teams could then migrate to a proper solution based on That said, I don't think teams currently have the bandwidth to make that migration. Sure, it would solve the race condition and allow them to update the navigation bar style when modals are opened, but if the current behavior is good enough for them, they probably won't prioritize it. |
Summary:
This PR removes
updateSystemAppearance()andsyncSystemBarsVisibility()along with their now-unused imports.On Android, every time a
<Modal>is shown,ReactModalHostView.updateSystemAppearance()reaches into the host activity'sWindowInsetsControllerand copies its status bar / navigation bar style and visibility onto the dialog window. This was the only way to keep modal windows visually consistent with the activity, since native modules likeStatusBarModuleonly operated on the activity window.This is now obsolete:
ExtraWindowEventListenerinterface, letting native modules be notified when extraWindows (e.g. modal dialogs) are created and destroyed.StatusBarModuleimplement that interface, so status bar style and visibility now sync to modal windows directly from the module that owns them.The navigation bar half of
updateSystemAppearance()is owned by third-party libraries (expo-navigation-bar,@zoontek/react-native-navigation-bar). Their next releases will implementExtraWindowEventListenerthe same wayStatusBarModuledoes, syncing nav bar style and visibility to modal windows from the module that owns them.At that point
updateSystemAppearance()is fully redundant: every concern it covered is handled by the module responsible for that configuration.Changelog:
[ANDROID] [REMOVED] - Remove manual system bar sync from
ReactModalHostView; modal windows are now configured by modules implementingExtraWindowEventListener(e.g.StatusBarModule).Test Plan:
<Modal>on Android and confirm the status bar style matches the host activity (light / dark content), now driven byStatusBarModule'sExtraWindowEventListener.<StatusBar barStyle="light-content" />/"dark-content"while a modal is open and confirm the change applies to the dialog window.<StatusBar hidden />before and during a modal presentation and confirm the dialog stays in sync with the activity.