fix escape key in dialog/drawer; closes #1457

This commit is contained in:
Cory LaViska
2023-07-18 12:37:52 -04:00
parent f954233bda
commit 201ff4efc5
3 changed files with 4 additions and 3 deletions

View File

@@ -132,7 +132,7 @@ export default class SlDialog extends ShoelaceElement {
}
private handleDocumentKeyDown = (event: KeyboardEvent) => {
if (this.open && event.key === 'Escape') {
if (event.key === 'Escape' && this.modal.isActive() && this.open) {
event.stopPropagation();
this.requestClose('keyboard');
}

View File

@@ -151,8 +151,8 @@ export default class SlDrawer extends ShoelaceElement {
}
private handleDocumentKeyDown = (event: KeyboardEvent) => {
if (this.open && !this.contained && event.key === 'Escape') {
event.stopPropagation();
if (event.key === 'Escape' && this.modal.isActive() && this.open && !this.contained) {
event.stopImmediatePropagation();
this.requestClose('keyboard');
}
};