From: Tim Düsterhus Date: Mon, 16 May 2022 09:37:27 +0000 (+0200) Subject: Revert "Suppress errors when disabling the focus trap" X-Git-Tag: 5.5.0_Beta_3~22 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=255236f624b2bb7a64bc1dc4e74753395524992a;p=GitHub%2FWoltLab%2FWCF.git Revert "Suppress errors when disabling the focus trap" This commit duplicates commit e9ffefb4d0db61bf8e12b3824c6515ac16fe3812 which is the cleaner fix, but was accidentally commited to `master` only. We revert this one to allow for a clean cherry-picking of e9ffefb4d0db61bf8e12b3824c6515ac16fe3812. This reverts commit e7439c4f5fc7daf8d45d2de478c488798ddf463a. --- diff --git a/ts/WoltLabSuite/Core/Ui/Dialog.ts b/ts/WoltLabSuite/Core/Ui/Dialog.ts index e2b42ce814..a0ac4c163b 100644 --- a/ts/WoltLabSuite/Core/Ui/Dialog.ts +++ b/ts/WoltLabSuite/Core/Ui/Dialog.ts @@ -783,18 +783,7 @@ const UiDialog = { throw new Error("Expected a valid dialog id, '" + id + "' does not match any active dialog."); } - try { - data.focusTrap.deactivate(); - } catch (e) { - // Suppress error messages if the focus could not be returned - // to the source element because it is no longer available or - // unknown. - const ignoreMessage = - "Your focus-trap must have at least one container with at least one tabbable node in it at all times"; - if (e.message !== ignoreMessage) { - throw e; - } - } + data.focusTrap.deactivate(); data.dialog.setAttribute("aria-hidden", "true"); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js index 8983a81c08..4e574134c1 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js @@ -644,18 +644,7 @@ define(["require", "exports", "tslib", "../Core", "../Dom/Change/Listener", "./S if (data === undefined) { throw new Error("Expected a valid dialog id, '" + id + "' does not match any active dialog."); } - try { - data.focusTrap.deactivate(); - } - catch (e) { - // Suppress error messages if the focus could not be returned - // to the source element because it is no longer available or - // unknown. - const ignoreMessage = "Your focus-trap must have at least one container with at least one tabbable node in it at all times"; - if (e.message !== ignoreMessage) { - throw e; - } - } + data.focusTrap.deactivate(); data.dialog.setAttribute("aria-hidden", "true"); // Move the keyboard focus away from a now hidden element. const activeElement = document.activeElement;