From 8cdce0c3029791697afbee956143d9371da463f5 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 6 Sep 2022 19:22:53 +0200 Subject: [PATCH] Bugfix: prevent issue with modal dialog supported `Esc` key to close --- dev/Knoin/AbstractViews.js | 4 ++-- dev/Knoin/Knoin.js | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/dev/Knoin/AbstractViews.js b/dev/Knoin/AbstractViews.js index d3722e216..4853a47b9 100644 --- a/dev/Knoin/AbstractViews.js +++ b/dev/Knoin/AbstractViews.js @@ -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 }); } diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index 0ee9dba05..8c4c11bcc 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -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) {