Bugfix: prevent issue with modal dialog supported Esc key to close

This commit is contained in:
the-djmaze 2022-09-06 19:22:53 +02:00
parent 2627a16c36
commit 8cdce0c302
2 changed files with 16 additions and 4 deletions

View file

@ -62,9 +62,9 @@ export class AbstractViewPopup extends AbstractView
shortcuts.add('escape,close', '', name, () => {
if (this.modalVisible() && false !== this.onClose()) {
this.close();
return false;
}
return true;
return false;
// return true; Issue with supported modal close
});
}

View file

@ -50,7 +50,7 @@ const
if (ViewTypePopup === position) {
vm.close = () => hideScreenPopup(ViewModelClass);
// Firefox / Safari HTMLDialogElement not defined
// Firefox < 98 / Safari < 15.4 HTMLDialogElement not defined
if (!vmDom.showModal) {
vmDom.classList.add('polyfill');
vmDom.showModal = () => {
@ -67,7 +67,19 @@ const
vmDom.removeAttribute('open', null);
vmDom.open = false;
};
/*
shortcuts.add('escape', '', vm.keyScope.scope, () => {
if (vmDom.open && false !== this.onClose()) {
this.close();
return false;
}
return true; Issue with supported modal close
});
*/
}
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/cancel_event
// vmDom.addEventListener('cancel', event => (false === vm.onClose() && event.preventDefault()));
// vmDom.addEventListener('close', () => false !== vm.onClose());
// show/hide popup/modal
const endShowHide = e => {
@ -174,7 +186,7 @@ const
// Close all popups
for (let vm of visiblePopups) {
false === vm.onClose() || vm.close();
(false === vm.onClose()) || vm.close();
}
if (screenName) {