Skip to content

Commit 9b116ad

Browse files
committed
Focus the first possible element in dialogs
See https://www.woltlab.com/community/thread/316063/
1 parent 9c4158e commit 9b116ad

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

ts/WoltLabSuite/Core/Element/woltlab-core-dialog.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* @since 6.0
1111
*/
1212

13+
import { tabbable } from "tabbable";
1314
import DomUtil from "../Dom/Util";
1415
import { adoptPageOverlayContainer, releasePageOverlayContainer } from "../Helper/PageOverlay";
1516
import * as Language from "../Language";
@@ -74,6 +75,11 @@ export class WoltlabCoreDialogElement extends HTMLElement {
7475

7576
adoptPageOverlayContainer(this.#dialog);
7677
scrollDisable();
78+
79+
const focusCandidates = tabbable(this.#dialog);
80+
if (focusCandidates.length > 0) {
81+
focusCandidates[0].focus();
82+
}
7783
}
7884

7985
close(): void {

wcfsetup/install/files/js/WoltLabSuite/Core/Element/woltlab-core-dialog.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)