0
0
Fork 0

refs #7124 perf: use find instead findIndex

This commit is contained in:
Javier Segarra 2024-03-22 07:32:21 +01:00
parent 561a7a5286
commit c4f7b5e7c0
1 changed files with 2 additions and 15 deletions

View File

@ -1,11 +1,6 @@
import { QForm } from 'quasar';
import { getCurrentInstance } from 'vue';
export default {
inject: { QForm },
component: { QForm },
components: { QForm },
extends: { QForm },
mounted: function () {
const vm = getCurrentInstance();
if (vm.type.name === 'QForm')
@ -14,19 +9,11 @@ export default {
// AUTOFOCUS
const elementsArray = Array.from(this.$el.elements);
const index = elementsArray.findIndex(element => element.classList.contains('q-field__native'));
const firstInputElement = elementsArray.find(element => element.classList.contains('q-field__native'));
if (index !== -1) {
const firstInputElement = elementsArray[index];
if (firstInputElement) {
firstInputElement.focus();
}
// KEYUP Event
document.addEventListener('keyup', function (evt) {
if (evt.keyCode === 13) {
that.onSubmit();
}
});
}
},
};