-
Notifications
You must be signed in to change notification settings - Fork 6.7k
ESC that cancels a modal: Stop event propagation #1692
Comments
It seems to be a duplicate of #1643 and that fix isn't released yet, it will be included in the next release. |
I think #1643 is unrelated. I am talking about the need to call evt.stopPropagation() on the keydown event in $modalStack. |
Sorry, should have read better. We could check if there is anything in the modalStack just by checking the length. Would changing the following line fix your problem? https://github.com/angular-ui/bootstrap/blob/master/src/modal/modal.js#L199 Change this if (evt.which === 27) { To this if (evt.which === 27 && $$stackedMap.length !== 0) { |
No, sorry for not making myself clear enough. if (evt.which === 27) {
modal = openedWindows.top();
if (modal && modal.value.keyboard) {
evt.stopPropagation(); // <<--- ADDED LINE If the ESC closes a modal window, it should be considered "consumed" and should not bubble up and also trigger an action somewhere up the DOM. |
It's an interesting case, in your case you would want a global option for the modals where you can disable the event listing for ESC? |
I'd guess, eekboom's point was the following: From user's point of view, the following happens: I'm experiencing exactly such an issue. So please consume the event if you take an action. |
@eekboom This is a valid point, but the correct fix would just |
If I press ESCAPE while a modal is open, in my app two things happen:
The modal closes (fine).
My app navigates to the parent state (speaking "angular-ui-router"-wise), which is due to a custom ESC handler I added.
angular-bootstrap should stop the keydown event propagation when a modal is closed with ESC, so that it does not trigger any further actions.
The text was updated successfully, but these errors were encountered: