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.

Controlled Modal UI Freezes

See original GitHub issue

Is this a bug report?

Yes

Environment

Environment: OS: macOS High Sierra 10.13.1 Node: 8.8.1 Yarn: 1.3.2 npm: 5.4.2 Watchman: 4.9.0 Xcode: Xcode 9.1 Build version 9B55 Android Studio: 3.0 AI-171.4408382

Packages: (wanted => installed) react: 16.0.0-beta.5 => 16.0.0-beta.5 react-native: https://github.com/expo/react-native/archive/sdk-22.0.2.tar.gz => 0.49.3

Target Platform: iOS (10.3)

Steps to Reproduce

  1. Create a controlled modal such as:
const Modal = ({ showModal, closeModal }) => (
  <Modal
    animationType="slide"
    transparent={false}
    visible={showModal}
    onRequestClose={() => {alert("Modal has been closed.")}}
    >
   <View style={{marginTop: 22}}>
     <Text>Hello World!</Text>
     <TouchableHighlight onPress={() => closeModal() }>
        <Text>Hide Modal</Text>
     </TouchableHighlight>
   </View>
  </Modal>
);
  1. Trigger the modal from a parent component, such as:
<View>
  <Modal
    showModal={this.state.showModal}
    closeModal={() => this.setState({ showModal: false })}
  />
  <ScrollView>
      {elements.map(element => {
        return (
          <Card key={element.id}>  
            <Badge onPress={() => this.setState({ showModal: true })>
              <Text>Show</Text>
            </Badge>
          </Card>
        );
      })}
  </ScrollView>
</View>
  1. Click open modal and it will open
  2. Click Hide Modal it will close and then reopen and the UI becomes unresponsive

Expected Behavior

I would expect the modal would open and then close again and wait till I click show modal again.

Actual Behavior

Modal opens up and when I press close, it closes and reopens and the UI becomes unresponsive.

Reproducible Demo

https://snack.expo.io/ByuRT9lxM

What I found out so far

The issue originates from:

componentWillUpdate() {
    UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);
    LayoutAnimation.easeInEaseOut();
  }

When I remove it all works as expected, so I guess there is some animation conflict? When I test it on my local emulator which is the latest iPhone I get the issue. When I test it on the android on snack.expo I get the issue. When I run the iOS device on snack.expo the issue isn’t there.

Thank you and Regards, Emir

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:20
  • Comments:31

github_iconTop GitHub Comments

14reactions
fdobrecommented, Aug 8, 2018

I have the same issue using RN0.55.4

7reactions
ithustlecommented, Nov 6, 2018

I’m also experiencing the same issue:

react: 16.6.0 react-native: 0.57.4 Android: 6

I can reproduce this issue with a physical Android device.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Native Controlled Modal Freezing - Stack Overflow
When I click the show modal button the modal pops-up as expected but when I click closeModal then the modal disappears and reappears...
Read more >
modal popup freezes parent window on close - Telerik
the application I am developing has a detail popup which opens model when it closes the parent window does not re-enable - the...
Read more >
freezing the UI with a modal popup or window, while work ...
The Window looks like a popup because it is borderless. It's intended to freeze the ui while a long sorting takes place. The...
Read more >
Modal dialogs freezing the screen - HTML & CSS - SitePoint
I have following HTML page where I am using the Bootstrap modal dialogs: For some reason whenever I click on "Add New User"...
Read more >
100180 - UI freezes if alert/dialog comes up while dragging ...
modal dialog document needed for testcase3 ... next, mozilla AND the XFree86 4.1.0 server completely lock up (kde2), only a CTRL-ALT-DEL recovers control...
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