mirror of
https://github.com/directus/directus.git
synced 2026-01-27 06:18:23 -05:00
Autofocus first input in create item form (#9583)
* autofocus first input in create form * add autofocus to translations interface * avoid setting firstEditableField to hidden fields * Base autofocus on prop Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -159,7 +159,7 @@ export default defineComponent({
|
||||
|
||||
const firstEditableFieldIndex = computed(() => {
|
||||
for (let i = 0; i < formFields.value.length; i++) {
|
||||
if (formFields.value[i].meta && !formFields.value[i].meta?.readonly) {
|
||||
if (formFields.value[i].meta && !formFields.value[i].meta?.readonly && !formFields.value[i].meta?.hidden) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
:model-value="firstItem"
|
||||
:initial-values="firstItemInitial"
|
||||
:badge="languageOptions.find((lang) => lang.value === firstLang)?.text"
|
||||
:autofocus="autofocus"
|
||||
@update:modelValue="updateValue($event, firstLang)"
|
||||
/>
|
||||
<v-divider />
|
||||
@@ -82,6 +83,10 @@ export default defineComponent({
|
||||
type: Array as PropType<(string | number | Record<string, any>)[] | null>,
|
||||
default: null,
|
||||
},
|
||||
autofocus: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
emits: ['input'],
|
||||
setup(props, { emit }) {
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
ref="form"
|
||||
:key="collection"
|
||||
v-model="edits"
|
||||
:autofocus="isNew"
|
||||
:disabled="isNew ? false : updateAllowed === false"
|
||||
:loading="loading"
|
||||
:initial-values="item"
|
||||
|
||||
Reference in New Issue
Block a user