-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS: UI will be blocked when show Alert while closing Modal #10471
Comments
+1 |
This is really frustrating. |
The opposite is also true, showing an alert in the same loop just before showing a modal will prevent the modal from being displayed |
Yes, I guess they are the some issue, so I just make it simple to demonstrate ? 2016?10?20??20:07?Morgan Laupies <notifications@github.commailto:notifications@github.com> ??? The opposite is also true, showing an alert in the same loop just before showing a modal will prevent the modal from being displayed You are receiving this because you authored the thread. |
I noticed same issue with experimental navigator. An Error while transitioning kills the animation and freezes UI. |
Looks like we need Any issues with NavigationExperimental should be filed separately. |
@ericvicenti I didn't use NE or Navigator in demo at all, and I don't think this issue is related to In my demo, I've show the different results when waiting for a certain milliseconds. I guess the Would someone expert in iOS take a look at this issue? |
ping @grabbou |
do someone have a fix for it? |
@DevBkIL my not great solution is to set a timeout, enough for the presented view controller to be the one under the Modal, and then present the Alert. Like I said, not great, but it's working until this can be properly resolved. |
Summary: further discussion: should there be a `onClose` or `onClosed` to pair with `onShow`? which would make a workaround for facebook#10471 much easier Closes facebook#10669 Differential Revision: D4133832 Pulled By: hramos fbshipit-source-id: 644a5bb6b9da697c81fc96ae4da196ba5b4050cb
Any update/resolution to this? We're still having problems with this a month after this issue was first reported. |
+1 |
I can confirm this using https://github.com/jaysoo/react-native-prompt any workaround? |
today I met the similar problem after I upgraded the react-native from 0.33 to 0.37. I want to show an Alert dialog after close the Modal, but Modal doesn't disappear, even after I close the Alert dialog and use the code likes following:
then I try to use
then the Modal will disappear, but, the Alert dialog can't display!!! I also tried run
but the same result, Alert dialog doesn't pop up yet. finally, I decide to hide Modal after I close the Alert dialog, and that works! code likes following:
|
@baurine
|
We are having a similar issue in niftylettuce/react-native-loading-spinner-overlay. Could it be that this is a more general issue relating to UI updating on state change rather than just a modal issue? |
cc @javache |
+1 |
1 similar comment
+1 |
+1, anyone has found solutions? |
Alert.alert cancels Modal dismiss even so we end up with a non responsive Modal confirmation dialog. This is explained here: facebook/react-native#10471 I used the workaround suggested in the thread by adding a short timeout to Alert.alert Todo: eventually we should better handle this by launching the error dialog from the teacher screen instead of redux, but this workaround is good for now.
Still having this issue. I am showing a loader on screen which is a Modal and then I need to show popup after API response. It works on Android to hide loader on Ok button action of Alert popup, but not working on iOS. Loader gets stuck on screen and popup never appears. |
It worked on android but not on iOS. Please suggest some solution. |
Hi guys, I think we may fixed it on latest |
Using of "AlertIOS" component for iOS helped me to avoid this issue. The workaround is as below;
|
@TechSatya are you confident about this? One would guess that Alert uses AlertIOS behind the scenes. |
Yes, @cristianoccazinsp I think this is the only possible solution as of now because the other availed solution didn't help me in any way. As from the last 2 days I was stuck in this issue, I started giving a try to the "AlertIOS" component and fortunately found it successful. Yes, Alerts uses AlertIOS behind it, but don't know how it got successful? Maybe something lacks in implementing of AlertIOS in Alert behind the scenes. To be more specific to the code for both platforms;
|
Using class ModalView extends React.Component {
state = {
visible: false
};
close({then} = {}) {
if (Platform.OS === 'ios') {
this.setState({visible: false, onDismiss: then});
} else {
this.setState({visible: false});
if (then !== undefined) {
then();
}
}
}
show() {
this.setState({visible: true});
}
render() {
return (
<Modal
visible={this.state.visible}
onDismiss={this.state.onDismiss}
{...this.props}>
{this.props.children}
</Modal>
)
}
} UsingJust replace your <ModalView ref={ref=>this.modalView=ref}
//other Modal props
>
//your components
<ModalView> Show Modalthis.modalView.show(); Close Modalthis.modalView.close(); Alert some messages after the modal closed. this.modalView.close({
then: () => {
Alert.alert('Hello World');
//your code
}
}); |
I have same issue here when i use "react-native": "0.59.9" and "react-native-modal": "^11.3.1" And my solution is show the alert in Modal onDismiss props |
Agree with @fengyouchao, your solution was working well. Thank you. |
I think facebook engineering need fix this bug. |
You can use my solution (prevent opening Modal when Alert is opened, and open it after Alert was closed, using redux and hooks). My solution is not full, later I will send solution that prevents opening many Modals at same time and prevents opening Alert while Modal is closing (based on queue and store subscribe). In any case, you can refine my idea. |
FWIW a modification to @fengyouchao's workaround if you are using async/await is
Then you can just |
Still an issue with RN 0.61.2 - does anyone if this is fixed in any later 0.61 patch releases? |
I have same issue. |
I have a similar problem, but the alert may appear at an undetermined point in time and is not logically dependent on Modal component. My workaround looks like this: const OldAlert = Alert.alert;
Alert.alert = (...args) => {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
OldAlert(...args);
});
});
}; This is “magic,” but it works for me. |
@revich2 interesting... Why do you need 2 @react-native-bot can we re open this? |
@cristianoccazinsp The first thing I used was |
in my case im change others Modal and resolved :D |
I still face that problem when close one modal and open other modal immediately. My current solution is using setTimeout but that's inconvenient. Have Facebook staff fixed it yet? Or someone has another solution? |
Same here. any update on this? |
Cause: Related bugs: Workaround: function BrokenModal() {
alert('this alert will show, modal wont');
return (
<View style={{height: 0}}>
<Modal animated>
<Text>This text will never appear</Text>
</Modal>
</View>
);
} |
When show Alert while closing Modal, the Alert dialog will disappear and the Modal will block the UI entirely even after reload, only on iOS.
The text was updated successfully, but these errors were encountered: