feat: refs #7790 updates

This commit is contained in:
Javier Segarra 2024-09-25 14:00:25 +02:00
parent 303062885a
commit c251b87272
1 changed files with 44 additions and 8 deletions

View File

@ -1,18 +1,54 @@
export default {
mounted() {
mounted: function () {
// func
const observer = new MutationObserver((mutations, observerInstance) => {
const firstInput = this?.$el?.querySelector(
'input:not([disabled]):not([type="checkbox"]), textarea:not([disabled]), [contenteditable]:not([disabled])'
);
if (firstInput?.form) {
firstInput.focus();
observerInstance.disconnect();
try {
// Login
const inputsFormCard = document.querySelectorAll(
'form.formCard input:not([disabled]):not([type="checkbox"])'
);
if (inputsFormCard.length) {
// .focus();
// observerInstance.disconnect();
// return;
focusFirstInput(inputsFormCard[0], observerInstance);
}
// VnNotes
const textareas = document.querySelectorAll(
'textarea:not([disabled]), [contenteditable]:not([disabled])'
);
if (textareas.length) {
// textareas[textareas.length - 1].focus();
// observerInstance.disconnect();
// return;
focusFirstInput(textareas[textareas.length - 1], observerInstance);
}
// if (!inputs || inputs.length === 0) return;
const inputs = document.querySelectorAll(
'form#formModel input:not([disabled]):not([type="checkbox"])'
);
const input = inputs[0];
if (!input) return;
// if (input.type === 'textarea' || input.form) {
// AUTOFOCUS
focusFirstInput(input, observerInstance);
// input.focus();
// observerInstance.disconnect();
} catch (error) {
console.error(error);
}
});
observer.observe(this.$el, {
childList: true,
subtree: true,
subtree: false,
});
},
};
function focusFirstInput(input, observerInstance) {
input.focus();
observerInstance.disconnect();
return;
}