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.

Modal transition glitches if one modal is hidden and other shown at the same time (iOS only)

See original GitHub issue

Environment

  Expo CLI 3.27.14 environment info:
    System:
      OS: macOS 10.15.5
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 10.20.1 - /var/folders/kc/w3zg_rmd6vnd_5w22fw154yh0000gn/T/yarn--1602600352442-0.37023497130992244/node
      Yarn: 1.22.5 - /var/folders/kc/w3zg_rmd6vnd_5w22fw154yh0000gn/T/yarn--1602600352442-0.37023497130992244/yarn
      npm: 6.14.4 - ~/.asdf/installs/nodejs/10.20.1/bin/npm
    SDKs:
      iOS SDK:
        Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
    IDEs:
      Xcode: 12.0.1/12A7300 - /usr/bin/xcodebuild
    npmPackages:
      expo: ~39.0.2 => 39.0.3
      react: 16.13.1 => 16.13.1
      react-dom: 16.13.1 => 16.13.1
      react-native: https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz => 0.63.2
      react-native-web: ~0.13.12 => 0.13.18
    Expo Workflow: managed

Platforms

iOS only

Versions

  • iOS: simulator, 14.0.1
  • react-native-modal: 11.5.6
  • react-native: 0.63.2
  • react: 16.13.1

Description

When switching between two modals using the same piece of state, on iOS the animation glitches and the 2nd modal never shows up. It’s there and it’s covering the content, breaking any pressable buttons underneath but it’s not visible (can be made visible by manually switching the isVisible prop off and on in React Native Debugger).

This does not happen on Android (there’s a bit of visual glitching but otherwise it’s fine) but does so on both iPhone and the simulator.

Reproducible Demo

https://snack.expo.io/gRtAP3xNO

  • Open demo on iPhone or download it and open locally on the iOS simulator
  • Press Trigger first modal
  • Press Trigger second modal

Expected outcome:

First modal fades away and second modal takes its place

Actual result

First modal disappears but second modal never shows up.

Note

This might be a duplicate of #481 or they may have a similar root cause

Workaround until this issue is fixed

  • Don’t use one piece of state to switch between two modals
  • When switching between modals, close the first one and wrap the code flipping the visibility of the second one in InteractionManager.runAfterInteractions to allow the first fade out animation to finish

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

6reactions
pistonskycommented, Nov 16, 2020

No need for any timeouts here. It’s a well-known issue: you can’t just simultaneously switch between modals. It’s also bad for UX. Instead, you should wait for one modal to finish its closing animation (by using onModalHide), and only after that show another modal.

3reactions
hbiedecommented, Apr 3, 2021

Even when using onModalHide I’m running into issues when I want to display for example an Alert.alert from onModalHide…

It will show up for a split second and disappear.

If I use setTimeout(func, 10), it will work. Has anyone else encountered this?

This was solved in #491. You should be able to use () => InteractionManager.runAfterInteractions(func) in onModalClose

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap: Open Another Modal in Modal - Stack Overflow
A potential issue in this case is that the backdrop from the 2nd modal hides the 1st modal. To prevent this, make the...
Read more >
10 Most Common Bootstrap Mistakes That Developers Make
Showing more than one modal prompt at the time. Bootstrap doesn't support overlapping modals. Only one modal at the time can be visible....
Read more >
ion-modal: Ionic Mobile App Custom Modal API Component
ion-modal is a dialog that appears on top of mobile app content, and must be dismissed before interaction resumes. Learn more about custom...
Read more >
Prevent Page Scrolling When a Modal is Open | CSS-Tricks
That's because modals are elements on a page just like any other. It may stay in place (assuming that's what it's meant to...
Read more >
iOS 14 (SwiftUI) Sheet Modals not … | Apple Developer Forums
I tried closing the modals in two different ways: either by using the Binding<Bool> method, or by using the Environment presentationMode method, and...
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