You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the Alert dialog on Android can be dismissed by tapping outside or pressing back button as well as pressing on any of the action buttons. The problem with this is that you've no way of knowing that the dialog was cancelled if the user cancels it by tapping outside.
For example, consider a location based app (my use case),
Check if GPS is enabled, if not, prompt the user to enable it
If the user chooses to enable GPS, wait for the location data
If the user cancels the dialog, fallback to something else
I'm not sure what'll be the correct way to handle this. Few things come to my mid,
But it might be the same constant for the Cancel button and tapping outside the dialog. Shouldn't that always do exactly the same thing? If there should be a button that does something else than dismiss the dialog (this is what tapping outside does), maybe it should be a different, third button?
I didn't see API for that on iOS so wanted to keep the API consistent.
Some users might not know that tapping outside the dialog dismisses it. Having the 'Cancel' button, Back button and tapping outside do exactly the same thing (usually, do nothing) sounds consistent from the UX perspective. What do you think?
@mkonicek Totally agree. The ideal behaviour would be to trigger same handler as cancel button.
We allow having a dialog without cancel button though. But I guess it's okay, because if the dev wanted to handle cancel event, he would have added a cancel button. I can send a PR to do this, if it's what we settle on.
I don't know what's the behaviour on iOS. Curious to know. cc @ide
On iOS you can't dismiss alerts by tapping outside of them (at least on an alert that I just tested). Would it be possible to design a clean API that acts almost the same whether the user tapped Cancel or tapped outside of the dialog, but also passes in a bit of extra information specifying how the dialog was canceled?
ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub.
Also, if this issue is a bug, please consider sending a PR with a fix.
We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.
how to dismiss an alert programmatically, any suggestions?
Reacted by gentlee, Adam Geoffrion, Dave Iverson, Jan Krajnak, Gustavo Gard, eassymo, Daniel Padilla, Dhanraj-bidchat, Janardhanrao, Kunal Chawla and 9 more
Reacted by Cristian Onescu, Mahmoud Mortada and Rovack
Activity
mkonicek commentedon Dec 24, 2015
The native module does say whether the dialog was dismissed:
https://github.com/facebook/react-native/blob/master/Libraries/Utilities/Alert.js#L115
But it might be the same constant for the Cancel button and tapping outside the dialog. Shouldn't that always do exactly the same thing? If there should be a button that does something else than dismiss the dialog (this is what tapping outside does), maybe it should be a different, third button?
I didn't see API for that on iOS so wanted to keep the API consistent.
mkonicek commentedon Dec 24, 2015
Some users might not know that tapping outside the dialog dismisses it. Having the 'Cancel' button, Back button and tapping outside do exactly the same thing (usually, do nothing) sounds consistent from the UX perspective. What do you think?
satya164 commentedon Dec 24, 2015
@mkonicek Totally agree. The ideal behaviour would be to trigger same handler as cancel button.
We allow having a dialog without cancel button though. But I guess it's okay, because if the dev wanted to handle cancel event, he would have added a cancel button. I can send a PR to do this, if it's what we settle on.
I don't know what's the behaviour on iOS. Curious to know. cc @ide
ide commentedon Dec 24, 2015
On iOS you can't dismiss alerts by tapping outside of them (at least on an alert that I just tested). Would it be possible to design a clean API that acts almost the same whether the user tapped Cancel or tapped outside of the dialog, but also passes in a bit of extra information specifying how the dialog was canceled?
satya164 commentedon Dec 25, 2015
@ide May be pass an event object or something like that?
mkonicek commentedon Apr 10, 2016
Hi there! This issue is being closed because it has been inactive for a while.
But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/add-a-dismiss-event-for-alert-dialog
ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub.
Also, if this issue is a bug, please consider sending a PR with a fix.
We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.
antonzy commentedon Aug 8, 2016
Any progress on this one?
Really annoying on Android....
satya164 commentedon Aug 9, 2016
@antonzy #8652 might help
droid-lover commentedon Dec 16, 2017
how to dismiss an alert programmatically, any suggestions?
sandropoluan commentedon Jan 28, 2018
Any update?
eassymo commentedon Mar 11, 2018
any update? x2
dann1609 commentedon Mar 30, 2018
any update? x3
kunalqss commentedon Apr 23, 2018
If you could give us a way to dismiss a dialog programmatically, that'd be great, thanks. 😁
bintoll commentedon May 25, 2018
I also think that it would be really great
rumbogs commentedon Jun 10, 2018
+1
droid-lover commentedon Jun 11, 2018
mmazzarolo commentedon Jun 11, 2018
🤔
huunovahub commentedon Jul 10, 2018
any update x4?