react-native: Modal showing activity bar when it should not (using SystemNavigationBar - edit: using java code produces the same bug)
Description
I’m using SystemNavigationBar to hide my status and activity bars, in order to be able to use the full screen for the app I’m currently developing.
-
The bug I’m facing (as many others faced already) consists on those same bars appearing when a modal is shown.
-
This is already a known issue on the package repo, but I could not find any issue regarding this problem on the react-native repo. Ence, I’m creating one.
-
This issue seems to have appeared before on react-native’s repo: https://github.com/facebook/react-native/commit/f8a4d281e2be5b68fbebf53f930d37d96236829c
Is there any fix?
Thanks in advance for any support and help.
React Native Version
0.71.4
Output of npx react-native info
System:
OS: Windows 10 10.0.22621
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 3.01 GB / 15.91 GB
Binaries:
Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 9.6.4 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowAllTrustedApps: Enabled
Versions: 10.0.19041.0
IDEs:
Android Studio: AI-213.7172.25.2113.9123335
Visual Studio: 16.11.32126.315 (Visual Studio Enterprise 2019)
Languages:
Java: 11.0.17
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.4 => 0.71.4
react-native-windows: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps to reproduce
- Create a screen with a button to open a modal with any content, like a button to close it;
- Import SystemNavigationBar, after installing it (npm i react-native-system-navigation-bar)
- Place:
SystemNavigationBar.fullScreen(true);inside your function - Run the code
- Both bars will be hidden
- Click on the button to open the modal
- When the modal opens, at least the bottom bar becomes visible
- Close the modal and both bars are hidden once again.
Snack, code example, screenshot, or link to a repository
App.tsx
import React, {useState} from 'react';
import {Modal, StyleSheet, View} from 'react-native';
import Buttons from './Buttons';
import SystemNavigationBar from 'react-native-system-navigation-bar';
function App(): JSX.Element {
SystemNavigationBar.fullScreen(true);
const [visible, setVisible] = useState(false);
const onclick = () => {
setVisible(!visible);
};
return (
<View style={styles.content}>
<Buttons
press={onclick}
text={'Open Modal'}
backgroundColor={'#FFFEFC'}
borderColor={'#EEEEEE'}
textColor={'#223631'}
/>
{visible === true && (
<Modal transparent={false} visible={visible}>
<View style={styles.content}>
<Buttons
press={onclick}
text={'Close Modal'}
backgroundColor={'#FFFEFC'}
borderColor={'#EEEEEE'}
textColor={'#223631'}
/>
</View>
</Modal>
)}
</View>
);
}
const styles = StyleSheet.create({
content: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});
export default App;
Buttons.tsx
import React from 'react';
import {Pressable, Text, View, StyleSheet} from 'react-native';
function Buttons({press, text, backgroundColor, borderColor, textColor}: any) {
return (
<Pressable
style={styles.button}
onPress={press}
backgroundColor={backgroundColor}
borderColor={borderColor}>
<View style={styles.textFrame}>
<Text style={styles.textStyle}>
<Text style={{color: textColor}}>{text}</Text>
</Text>
</View>
</Pressable>
);
}
const styles = StyleSheet.create({
button: {
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
// paddingVertical: 24,
// paddingHorizontal: 24,
// alignSelf: 'stretch',
// flexGrow: 0,
borderWidth: 4,
borderRadius: 16,
height: 88,
width: 500,
},
textFrame: {
display: 'flex',
order: 0,
flexDirection: 'row',
},
textStyle: {
display: 'flex',
fontFamily: 'OpenSans-SemiBold',
fontStyle: 'normal',
fontWeight: '600',
fontSize: 32,
},
});
export default Buttons;
Example:
Here, we can see that, at the bottom, after clicking on the open modal button, the bar appears, where it should not.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 18 (1 by maintainers)
I’m doing another attempt to fix this issue in https://github.com/facebook/react-native/pull/48516, also taking into account the feedback from the previous PR which was also aiming to fix this.
For anyone looking for a workaround, I’ve opted to stop using
Modaluntil this has been resolved, and I’m instead using react-native-portal to “teleport” my modals to the root of my view hierarchy so that I can show the content on top of everything else.Thanks!
this is still open
@cortinico Is this a known issue , A PR has also been raised with the fix,Is this in the pipeline,
Thanks in advance
Problem persist in 0.71.10.