0
0
Fork 0

fix: disable firstInput.focus

This commit is contained in:
Javier Segarra 2024-07-26 06:21:39 +02:00
parent 1a9cdee838
commit a27ac46f9f
1 changed files with 16 additions and 15 deletions

View File

@ -3,28 +3,29 @@ import { getCurrentInstance } from 'vue';
const filterAvailableInput = (element) => { const filterAvailableInput = (element) => {
return element.classList.contains('q-field__native') && !element.disabled; return element.classList.contains('q-field__native') && !element.disabled;
}; };
const filterAvailableText = (element) => { // const filterAvailableText = (element) => {
const parentComponent = element.__vueParentComponent; // const parentComponent = element.__vueParentComponent;
if (!parentComponent) return element.attributes.component.nodeValue !== 'input'; // if (!parentComponent)
return ( // return element.attributes.component.nodeValue !== 'input';
parentComponent?.type.name === 'QInput' && // return (
parentComponent?.attrs?.class !== 'vn-input-date' // parentComponent?.type.name === 'QInput' &&
); // parentComponent?.attrs?.class !== 'vn-input-date'
}; // );
// };
export default { export default {
mounted: function () { mounted: function () {
const vm = getCurrentInstance(); const vm = getCurrentInstance();
if (vm.type.name === 'QForm') { if (vm.type.name === 'QForm') {
if (!['searchbarForm', 'filterPanelForm'].includes(this.$el?.id)) { if (!['searchbarForm', 'filterPanelForm'].includes(this.$el?.id)) {
// AUTOFOCUS // TODO: AUTOFOCUS IS NOT FOCUSING
const elementsArray = Array.from(this.$el.elements); // const elementsArray = Array.from(this.$el.elements);
const availableInputs = elementsArray.filter(filterAvailableInput); // const availableInputs = elementsArray.filter(filterAvailableInput);
const firstInputElement = availableInputs.find(filterAvailableText); // const firstInputElement = availableInputs.find(filterAvailableText);
if (firstInputElement) { // if (firstInputElement) {
firstInputElement.focus(); // firstInputElement.focus();
} // }
const that = this; const that = this;
this.$el.addEventListener('keyup', function (evt) { this.$el.addEventListener('keyup', function (evt) {
if (evt.key === 'Enter') { if (evt.key === 'Enter') {