forked from verdnatura/salix-front
Merge pull request '#7124 - First Input Autofocus without property' (!251) from 7124_autofocus_first_input into dev
Reviewed-on: verdnatura/salix-front#251 Reviewed-by: Javi Gallego <jgallego@verdnatura.es> Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
commit
413beb9b84
|
@ -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,21 @@
|
|||
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();
|
||||
if (vm.type.name === 'QForm')
|
||||
if (!['searchbarForm','filterPanelForm'].includes(this.$el?.id)) {
|
||||
// AUTOFOCUS
|
||||
const elementsArray = Array.from(this.$el.elements);
|
||||
const firstInputElement = elementsArray.filter(filterAvailableInput).find(filterAvailableText);
|
||||
|
||||
if (firstInputElement) {
|
||||
firstInputElement.focus();
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
|
@ -0,0 +1,6 @@
|
|||
import { boot } from 'quasar/wrappers';
|
||||
import qFormMixin from './qformMixin';
|
||||
|
||||
export default boot(({ app }) => {
|
||||
app.mixin(qFormMixin);
|
||||
});
|
|
@ -164,7 +164,7 @@ function formatValue(value) {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<QForm @submit="search">
|
||||
<QForm @submit="search" id="filterPanelForm">
|
||||
<QList dense>
|
||||
<QItem class="q-mt-xs">
|
||||
<QItemSection top>
|
||||
|
|
|
@ -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