From 8a82b7ab38a27925842c69dd771beb7bf40a0007 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 22 Mar 2024 09:55:16 +0100 Subject: [PATCH] refs #7124 perf: avoid focus in disabled fields --- src/boot/qformMixin.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/boot/qformMixin.js b/src/boot/qformMixin.js index 66e3de4f5..8c89c9202 100644 --- a/src/boot/qformMixin.js +++ b/src/boot/qformMixin.js @@ -1,5 +1,9 @@ import { getCurrentInstance } from 'vue'; +const filterAvailableInput = element => element.classList.contains('q-field__native') && !element.disabled +const filterAvailableText = element => element.__vueParentComponent.type.name === 'QInput' && element.__vueParentComponent?.attrs?.class !== 'vn-input-date'; + + export default { mounted: function () { const vm = getCurrentInstance(); @@ -7,7 +11,7 @@ export default { if (!['searchbarForm','filterPanelForm'].includes(this.$el?.id)) { // AUTOFOCUS const elementsArray = Array.from(this.$el.elements); - const firstInputElement = elementsArray.find(element => element.classList.contains('q-field__native')); + const firstInputElement = elementsArray.filter(filterAvailableInput).find(filterAvailableText); if (firstInputElement) { firstInputElement.focus();