From 255236f624b2bb7a64bc1dc4e74753395524992a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 16 May 2022 11:37:27 +0200 Subject: [PATCH] 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. --- ts/WoltLabSuite/Core/Ui/Dialog.ts | 13 +------------ .../install/files/js/WoltLabSuite/Core/Ui/Dialog.js | 13 +------------ 2 files changed, 2 insertions(+), 24 deletions(-) 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; -- 2.20.1