Bug
https://codepen.io/jakobadam/pen/zaxVBO?editors=1010
escapeToClose: trueThe front most dialog should close
All dialogs closes
N/A
Consider replacing ev.stopPropagation with ev.stopImmediatePropagation so only one event listener is triggered:
https://github.com/angular/material/blob/master/src/components/dialog/dialog.js#L967
I cannot reproduce this with the CodePen provided. You mentioned All browsers, but I tried with Chrome Stable (Version 67.0.3396.62 (Official Build) (64-bit)). You also mentioned All OS, I tried with macOS High Sierra.
I did the following:
Did I miss something or is this specific to a certain browser?
Splaktar: I also can't reproduce the issue with only two dialogs, but if > 2 dialogs are opened, hitting escape will close all but one dialog. This is not the expected behavior. Expected behavior is that it closes the top dialog only.
Two variants:
1a. First ESC exits the input.
1b. First ESC triggers close of the dialog.
Note: After 1a and 1b focus is on body.
I can reproduce variant 1a on:
And variant 1b on:
OK, yeah if I open 3+ dialogs, I can see that sometimes the ESC closes multiple dialogs instead of just one per keypress.
I can't reproduce ESC removing focus on an input. Perhaps that's an Ubuntu-specific behavior.
The z-index of the md-backdrop when open 1+ dialogs not is correct
@TemitaTom please open a separate issue for that unless you can verify that is what is causing this issue.
As for investigating this issue, the code that handles hiding dialogs (and other interimElements) can be found here:
https://github.com/angular/material/blob/v1.1.10/src/core/services/interimElement/interimElement.js#L338-L377
It does this to remove the last dialog added:
// Hide the latest showing interim element.
return closeElement(showingInterims[showingInterims.length - 1]);
Can confirm this is an issue in Chrome 69.0.3497.92 on macOS, using Angular Material 1.1.10 and Angular 1.7.4
I did some manual tests and @jakobadam is 100% correct, we should be using stopImmediatePropagation. I have done manual testing and made a PR. 馃悢
@Splaktar if you can add him to my PR somehow so he gets credit that would be great, not sure if that's possible though.
@codymikol just mentioning him and linking to his comment with the suggested fix in your PR is the way to do that.
@Splaktar I added a test. It's the best I could to to reproduce the issue in a test, but it doesn't fail in master :/.
Thanks for getting this in:) Our users can now close dialogs with ESC again...
@jakobadam glad this helped you out :D
Most helpful comment
Thanks for getting this in:) Our users can now close dialogs with ESC again...