Initial
This commit is contained in:
13
web/js/src/focusFirstInput.js
Normal file
13
web/js/src/focusFirstInput.js
Normal file
@@ -0,0 +1,13 @@
|
||||
// If no dialog is open, focus first input in main content form
|
||||
// TODO: Replace this with autofocus attributes in the HTML
|
||||
export default function focusFirstInput() {
|
||||
const openDialogs = document.querySelectorAll('dialog[open]');
|
||||
if (openDialogs.length === 0) {
|
||||
const input = document.querySelector(
|
||||
'#main-form .form-control:not([disabled]), #main-form .form-select:not([disabled])'
|
||||
);
|
||||
if (input) {
|
||||
input.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user