question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Header in modal is sometimes missing background on iOS 13 & 14

See original GitHub issue

Description

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: Screenshot 2022-04-04 at 11 37 15

Header inspected in Flipper when it works: Screenshot 2022-04-04 at 11 30 32

When the bug occurs: Screenshot 2022-04-04 at 11 37 31

Header inspected in Flipper when bug occurs: Screenshot 2022-04-04 at 11 29 38

Steps To Reproduce

  1. Run the app on either iOS 13 or iOS 14
  2. Open the modal
  3. 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

  1. Unpack
  2. npm i
  3. npx pod-install
  4. 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:closed
  • Created a year ago
  • Reactions:8
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
codeioncommented, May 16, 2022

Happens with presentation: ‘card’ as well.

0reactions
itsramielcommented, Jun 14, 2022

@escwald did you solve it

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found