fix escape key in dialog/drawer; closes #1457

pull/1460/head
Cory LaViska 2023-07-18 12:37:52 -04:00
rodzic f954233bda
commit 201ff4efc5
3 zmienionych plików z 4 dodań i 3 usunięć

Wyświetl plik

@ -24,6 +24,7 @@ New versions of Shoelace are released as-needed and generally occur when a criti
- Fixed a bug in `<sl-carousel>` that caused navigation to work incorrectly in some case [#1420]
- Fixed a number of slots that incorrectly had aria- and/or role attributes directly on them [#1422]
- Fixed a bug in `<sl-tree>` that caused focus to be stolen when removing focused tree items [#1430]
- Fixed a bug in `<sl-dialog>` and `<sl-drawer>` that caused nested modals to respond too eagerly to the [[Esc]] key [#1457]
- Updated ESLint and related plugins to the latest versions
## 2.5.2

Wyświetl plik

@ -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');
}

Wyświetl plik

@ -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');
}
};