#7124 - First Input Autofocus without property #251
|
@ -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
|
||||
jsegarra marked this conversation as resolved
Outdated
|
||||
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'));
|
||||
|
||||
jsegarra marked this conversation as resolved
alexm
commented
No usar una variable si luego solo se usa una vez. Igual se te ha quedado de antes No usar una variable si luego solo se usa una vez. Igual se te ha quedado de antes
jsegarra
commented
Si que se usaba en el evento key, pero eso pertenece a otra rama Si que se usaba en el evento key, pero eso pertenece a otra rama
|
||||
if (index !== -1) {
|
||||
const firstInputElement = elementsArray[index];
|
||||
if (firstInputElement) {
|
||||
firstInputElement.focus();
|
||||
}
|
||||
|
||||
// KEYUP Event
|
||||
document.addEventListener('keyup', function (evt) {
|
||||
if (evt.keyCode === 13) {
|
||||
that.onSubmit();
|
||||
}
|
||||
});
|
||||
}
|
||||
jsegarra marked this conversation as resolved
jgallego
commented
refactor de chatGpt para no usar -1 if (firstInputElement) { refactor de chatGpt para no usar -1
const firstInputElement = elementsArray.find(element => element.classList.contains('q-field__native'));
if (firstInputElement) {
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Justo he probado en claimBasicData (ejemplo: http://localhost:9000/#/claim/1/basic-data) y es curioso pq no funciona. Dado que el primer elemento si es un input pero esta disabled. Igual se podría añadir que comprobase que no tenga la clase
.disabled
Si, es una posibilidad que había visto pero no contemplado.
Lo tengo en cuenta para mas cambios
me parece muy interesante que obvie los disables