#7124 - First Input Autofocus without property #251
|
@ -29,7 +29,7 @@ module.exports = configure(function (/* ctx */) {
|
|||
// app boot file (/src/boot)
|
||||
// --> boot files are part of "main.js"
|
||||
// https://v2.quasar.dev/quasar-cli/boot-files
|
||||
boot: ['i18n', 'axios', 'vnDate', 'validations'],
|
||||
boot: ['i18n', 'axios', 'vnDate', 'validations', 'quasar'],
|
||||
|
||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
|
||||
css: ['app.scss'],
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import { QForm } from 'quasar';
|
||||
import { getCurrentInstance } from 'vue';
|
||||
|
||||
export default {
|
||||
inject: { QForm },
|
||||
component: { QForm },
|
||||
components: { QForm },
|
||||
extends: { QForm },
|
||||
mounted: function () {
|
||||
const vm = getCurrentInstance();
|
||||
jsegarra marked this conversation as resolved
Outdated
|
||||
if (vm.type.name === 'QForm')
|
||||
if (![ 'searchbarForm'].includes(this.$el?.id)) {
|
||||
let that = this;
|
||||
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
|
||||
|
||||
// AUTOFOCUS
|
||||
const elementsArray = Array.from(this.$el.elements);
|
||||
const index = elementsArray.findIndex(element => element.classList.contains('q-field__native'));
|
||||
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) {
|
||||
|
||||
if (index !== -1) {
|
||||
const firstInputElement = elementsArray[index];
|
||||
firstInputElement.focus();
|
||||
}
|
||||
|
||||
// KEYUP Event
|
||||
document.addEventListener('keyup', function (evt) {
|
||||
if (evt.keyCode === 13) {
|
||||
jsegarra marked this conversation as resolved
Outdated
jsegarra
commented
Este código pertenece a otra rama Este código pertenece a otra rama
jsegarra
commented
KeyCode is deprecated 👀 KeyCode is deprecated 👀
|
||||
that.onSubmit();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
|
@ -0,0 +1,6 @@
|
|||
import { boot } from 'quasar/wrappers';
|
||||
import qFormMixin from './qformMixin';
|
||||
|
||||
export default boot(({ app }) => {
|
||||
app.mixin(qFormMixin);
|
||||
});
|
|
@ -108,7 +108,7 @@ async function search() {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<QForm @submit="search">
|
||||
<QForm @submit="search" id="searchbarForm">
|
||||
<VnInput
|
||||
id="searchbar"
|
||||
v-model="searchText"
|
||||
|
|
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