refs #7124 perf: use find instead findIndex
This commit is contained in:
parent
561a7a5286
commit
c4f7b5e7c0
|
@ -1,11 +1,6 @@
|
||||||
import { QForm } from 'quasar';
|
|
||||||
import { getCurrentInstance } from 'vue';
|
import { getCurrentInstance } from 'vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: { QForm },
|
|
||||||
component: { QForm },
|
|
||||||
components: { QForm },
|
|
||||||
extends: { QForm },
|
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
const vm = getCurrentInstance();
|
const vm = getCurrentInstance();
|
||||||
if (vm.type.name === 'QForm')
|
if (vm.type.name === 'QForm')
|
||||||
|
@ -14,19 +9,11 @@ export default {
|
||||||
|
|
||||||
// AUTOFOCUS
|
// AUTOFOCUS
|
||||||
const elementsArray = Array.from(this.$el.elements);
|
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) {
|
if (firstInputElement) {
|
||||||
const firstInputElement = elementsArray[index];
|
|
||||||
firstInputElement.focus();
|
firstInputElement.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// KEYUP Event
|
|
||||||
document.addEventListener('keyup', function (evt) {
|
|
||||||
if (evt.keyCode === 13) {
|
|
||||||
that.onSubmit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue