Double-click show modal bug

I’ve been encountering a bug when I double click a button that shows a modal. What happens is it will show two of the same modals.

When I close the first modal, the second one will still be displayed and since I removed the scope of the first one, it seems like Ionic removes the close listener for the second, so I’m unable to close it.

This is really only a bug with iOS since on Android, clicking the back button will close it, but its still annoying for iOS users.

My current implementation is I created a bunch of modal directives, and using the ‘slide-in-right’ animation, I’m able to get them to work as “tabs” in a way. It works great except for this bug.

I think the solution would be to first check if the scope’s modal is defined. If so, remove it. If not, and the user is still clicking the close button, to check the DOM for a second modal and close that one. But I’m not sure what events to emit or the best way to do this.

Any help would be much appreciated.

Cheers!

Also, the reason I don’t like just hiding the modal is it will stay on the dom, so if a user opens a few modals, it will start to have a noticeable slow down.