feat: refs #7790 updates
This commit is contained in:
parent
303062885a
commit
c251b87272
|
@ -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])'
|
||||
try {
|
||||
// Login
|
||||
const inputsFormCard = document.querySelectorAll(
|
||||
'form.formCard input:not([disabled]):not([type="checkbox"])'
|
||||
);
|
||||
if (firstInput?.form) {
|
||||
firstInput.focus();
|
||||
observerInstance.disconnect();
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue