Multiple Alerts stacked on iOS instead of being replaced
See original GitHub issueIs this a bug report?
Yes
Have you read the Bugs section of the Contributing to React Native Guide?
yes
Environment
react-native-cli: 1.0.0 react-native: 0.43.4 (simulator screenshots) and 0.45.1 (Expo demo) node: v7.7.4 npm: 4.1.2
Then, specify:
- Target Platform: iOS
- Development Operating System macOS Sierra
- Build tools Xcode (8.3)
Steps to Reproduce
Displaying successive Alerts on iOS leads to an overlay (multiple Alerts displayed, you need to click them one by one to get back to the app)
Alert.alert('title', 'lorem', [
{ text: 'cancel', onPress: () => true },
{ text: 'read', onPress: () => this.doWhatever() },
]);
Expected Behavior
On Android, if an Alert is already displayed when calling Alert.alert
the new Alert replace the previous one. It should be the same on iOS since there is no way to delete / cancel alert without pressing the buttons on it.
Actual Behavior
Alerts are stacked on iOS instead of being replaced when a new one is created, both on simulator and on device, even build with a release scheme.
![](https://user-images.githubusercontent.com/7557608/27933655-99d9bfb6-62a2-11e7-9cf4-ef3d5401b7a5.png)
![](https://user-images.githubusercontent.com/7557608/27933653-99d7dc46-62a2-11e7-95f1-b56a37e3bc74.png)
![](https://user-images.githubusercontent.com/7557608/27933656-99da0eda-62a2-11e7-8809-7b6220aeb183.png)
![](https://user-images.githubusercontent.com/7557608/27933651-99d7cef4-62a2-11e7-8c40-ed8d4a304a32.png)
![](https://user-images.githubusercontent.com/7557608/27933654-99d8ad92-62a2-11e7-9bc7-05dde1f6acec.png)
![](https://user-images.githubusercontent.com/7557608/27933652-99d7d1ce-62a2-11e7-82a6-4eb7b3d88dbf.png)
![](https://user-images.githubusercontent.com/7557608/27933657-99eae746-62a2-11e7-8565-476d09296865.png)
Reproducible Demo
I’ve setup an Expo project here: run it on iOS to reproduce the bug.
https://github.com/weassur/RNAlertBug
and a snack:
https://snack.expo.io/rynGz03N-
there are no dependencies other than to the Alert API
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:5 (2 by maintainers)
I always thought this was expected iOS behaviour. Agreed it’s annoying as you can’t have the same code base to handle alerts.
Is there a way to close old Alert before showing the new one ?