35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
function focusFirstInput(input) {
|
|
input.focus();
|
|
}
|
|
export default {
|
|
mounted: function () {
|
|
const that = this;
|
|
|
|
const form = document.querySelector('.q-form#formModel');
|
|
if (!form) return;
|
|
try {
|
|
const inputsFormCard = form.querySelectorAll(
|
|
`input:not([disabled]):not([type="checkbox"])`,
|
|
);
|
|
if (inputsFormCard.length) {
|
|
focusFirstInput(inputsFormCard[0]);
|
|
}
|
|
const textareas = document.querySelectorAll(
|
|
'textarea:not([disabled]), [contenteditable]:not([disabled])',
|
|
);
|
|
if (textareas.length) {
|
|
focusFirstInput(textareas[textareas.length - 1]);
|
|
}
|
|
const inputs = document.querySelectorAll(
|
|
'form#formModel input:not([disabled]):not([type="checkbox"])',
|
|
);
|
|
const input = inputs[0];
|
|
if (!input) return;
|
|
|
|
focusFirstInput(input);
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
},
|
|
};
|