fix(dialog): escape key not working once element loses focus#3082
Conversation
Fixes issue in the dialog that prevented the user from being able to close via the escape key, if any of the elements inside the dialog loses focus. Fixes angular#3009.
| this._attachDialogContent(componentOrTemplateRef, dialogContainer, overlayRef, config); | ||
|
|
||
| if (!this._openDialogs.length && !this._parentDialog) { | ||
| document.addEventListener('keydown', this._boundKeydown); |
There was a problem hiding this comment.
I guess we don't have access to a Renerer we can use to do this at this point in the code?
There was a problem hiding this comment.
We don't. Angular only injects the renderer in components.
|
Wouldnt it have been better to use HostListener instead?
This would attach a listener on the document rather than the element, thus preventing this bug. I am unsure why the MD team prefers the use of |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fixes issue in the dialog that prevented the user from being able to close via the escape key, if any of the elements inside the dialog loses focus.
Fixes #3009.