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) => {
switch (evt.key) {
case 'Escape': {
evt.preventDefault();
evt.stopPropagation();
this.completeCancelled();
window.removeEventListener('keydown', keyListenerBound);
break;
// does it really matter where we check?
const topModal = document.elementFromPoint(window.innerWidth / 2, window.innerHeight / 2)?.closest('.shadow_popup');
if (topModal == this.dom) {
evt.preventDefault();
evt.stopPropagation();
this.completeCancelled();
window.removeEventListener('keydown', keyListenerBound);
break;
}
}
}
};