From 65dbb26e7a69fc3cf9bb9819b82bc535db3645b3 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 29 Jun 2022 15:47:47 +0200 Subject: [PATCH] Delay the auto focus of the submit button Safari delays the execution of the `blur` event on the document which causes the focus shift to happen too early. Delaying it by two event cycles are enough to provide a consistent experience and to avoid conflicts with the focus trap. See https://www.woltlab.com/community/thread/296069-best%C3%A4tigung-bei-installation-von-paket-%C3%BCber-entwickler-werkzeuge-nicht-direkt-pe/ --- ts/WoltLabSuite/Core/Ui/Confirmation.ts | 6 ++++-- .../install/files/js/WoltLabSuite/Core/Ui/Confirmation.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ts/WoltLabSuite/Core/Ui/Confirmation.ts b/ts/WoltLabSuite/Core/Ui/Confirmation.ts index 5de324c8c3..90bdb6ff0b 100644 --- a/ts/WoltLabSuite/Core/Ui/Confirmation.ts +++ b/ts/WoltLabSuite/Core/Ui/Confirmation.ts @@ -122,8 +122,10 @@ class UiConfirmation implements DialogCallbackObject { * Sets the focus on the confirm button on dialog open for proper keyboard support. */ _onShow(): void { - this.confirmButton.blur(); - this.confirmButton.focus(); + window.setTimeout(() => { + this.confirmButton.blur(); + this.confirmButton.focus(); + }, 1); } _dialogSetup(): ReturnType { diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Confirmation.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Confirmation.js index f2d59027e4..193fce76ef 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Confirmation.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Confirmation.js @@ -93,8 +93,10 @@ define(["require", "exports", "tslib", "../Core", "../Language", "./Dialog"], fu * Sets the focus on the confirm button on dialog open for proper keyboard support. */ _onShow() { - this.confirmButton.blur(); - this.confirmButton.focus(); + window.setTimeout(() => { + this.confirmButton.blur(); + this.confirmButton.focus(); + }, 1); } _dialogSetup() { return { -- 2.20.1