Android - Modal with `statusBarTranslucent` has wrong height
j-piasecki opened this issue · 6 comments
Description
On the old architecture, when using a Modal
with no animation and translucent status bar, a layout flash is noticeable when the modal is opened. Here's the video of this happening (it's visible for one frame):
old_arch.mov
On the new architecture, the issue is more problematic as the modal keeps the wrong height:
new_arch.mov
I believe the problem may be with this line as the windowFullscreen
will be true only when the relevant property is set on the app's theme, and not when the View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
flag is set on view (which is the case here).
The flash on the old arch comes from the fact that the height is updated here to the correct value. This is also the case for the new arch, however, the correct values get overwritten with every state update.
This also happens on 0.71.0-rc.6.
Simply removing the state updates here and here, which I've done in #35803, seems to be solving the problem (at the cost of the modal appearing one frame later), however, I'm not that familiar with the code so it may have some unintended consequences.
Version
0.70.5
Output of npx react-native info
System:
OS: macOS 12.6
CPU: (8) arm64 Apple M1 Pro
Memory: 100.31 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
Watchman: 2022.10.24.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/lib/ruby/gems/3.0.0/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
Android SDK:
API Levels: 24, 26, 28, 29, 30, 31, 32, 33
Build Tools: 26.0.3, 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0
System Images: android-28 | Google ARM64-V8a Play ARM 64 v8a, android-32 | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2021.3 AI-213.7172.25.2113.9123335
Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
Languages:
Java: 11.0.14 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.5 => 0.70.5
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps to reproduce
Create a Modal
with animationType="none"
and statusBarTranslucent={true}
and open it.
Snack, code example, screenshot, or link to a repository
import React, {useState} from 'react';
import {View, Button, Modal} from 'react-native';
const App = () => {
const [open, setOpen] = useState(false);
return (
<View style={{flex: 1, backgroundColor: 'yellow'}}>
<Button
title="Open"
onPress={() => {
setOpen(true);
}}
/>
<Modal
visible={open}
animationType="none"
statusBarTranslucent={true}>
<View style={{flex: 1, backgroundColor: 'red'}}>
<Button
title="Close"
onPress={() => {
setOpen(false);
}}
/>
</View>
</Modal>
</View>
);
};
export default App;