Merge pull request #2103 from LenAnderson/fix-popup-escape

only close last popup with escape
This commit is contained in:
Cohee 2024-04-19 01:15:03 +03:00 committed by GitHub
commit 5084b4ae64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 5 deletions

View File

@ -119,11 +119,15 @@ export class Popup {
const keyListener = (evt) => { const keyListener = (evt) => {
switch (evt.key) { switch (evt.key) {
case 'Escape': { case 'Escape': {
evt.preventDefault(); // does it really matter where we check?
evt.stopPropagation(); const topModal = document.elementFromPoint(window.innerWidth / 2, window.innerHeight / 2)?.closest('.shadow_popup');
this.completeCancelled(); if (topModal == this.dom) {
window.removeEventListener('keydown', keyListenerBound); evt.preventDefault();
break; evt.stopPropagation();
this.completeCancelled();
window.removeEventListener('keydown', keyListenerBound);
break;
}
} }
} }
}; };