Header in modal is sometimes missing background on iOS 13 & 14
See original GitHub issueDescription
Providing headerLeft
and headerRight
with a component for a modal screen can result in an incorrect header background on iOS 13 & 14 (cannot be reproducible on iOS 12 & 15). This does not happen every time (about 50% of the time), but is easily reproducible by re-opening the modal until it appears.
Example
<Stack.Navigator
screenOptions={{
headerStyle: {
backgroundColor: 'pink',
},
}}
initialRouteName='Main'
>
<Stack.Group screenOptions={{ presentation: 'modal' }}>
<Stack.Screen
name='Search'
component={Search}
options={{
headerLeft: () => <View />,
}}
/>
</Stack.Group>
<Stack.Screen name='Main' component={Main} />
</Stack.Navigator>
The bug occurs even if you do not provide the backgroundColor
, but providing one makes it more clear when it occurs.
Screenshots
When it works:
Header inspected in Flipper when it works:
When the bug occurs:
Header inspected in Flipper when bug occurs:
Steps To Reproduce
- Run the app on either iOS 13 or iOS 14
- Open the modal
- If bug does not occur, go back and redo previous step.
Expected behavior
Modal is always opened with correct background color in its header
Actual behavior
Sometimes opened with a gradient effect background
Reproduction
Minimial app using bare workflow: modal-test.zip
- Unpack
npm i
npx pod-install
npm run ios
Platform
- iOS
- Android
- Web
- Windows
- tvOS
Workflow
- Managed workflow
- Bare workflow
Package versions
package | version |
---|---|
react-native | 0.67.3 |
@react-navigation/native | 6.0.10 |
@react-navigation/native-stack | 6.6.1 |
react-native-screens | 3.13.1 |
react-native-safe-area-context | 4.2.4 |
Issue Analytics
- State:
- Created a year ago
- Reactions:8
- Comments:6 (2 by maintainers)
Top Results From Across the Web
iOS 14 (SwiftUI) Sheet Modals not … | Apple Developer Forums
Sometimes a modal is automatically (non-desired) closed right after it opens, and after that, the modal works fine (and so it is not...
Read more >Bootstrap modal appearing under background - Stack Overflow
Make sure the modal container and all of its parent elements are positioned the default way to fix the problem. Here are a...
Read more >Bootstrap Modal Dialog showing under Modal Background
This setup works because there's no top level container above the modal that introduces it's own positioning root. Problem solved, right?
Read more >View Controller Presentation Changes in iOS 13
Default Modal Presentation Style Change ... The default presentation is now page sheet, not full screen. The header documentation for modalPresentationStyle says:.
Read more >Fucking SwiftUI - Cheat Sheet
Xcode 11 for SwiftUI and Xcode 12 beta for iOS 14 features (Download beta software from Apple); iOS 13 / macOS 10.15 /...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Happens with presentation: ‘card’ as well.
@escwald did you solve it