diff --git a/app/src/composables/use-form-fields/use-form-fields.ts b/app/src/composables/use-form-fields/use-form-fields.ts index 3a3c2cf092..965de9ca3f 100644 --- a/app/src/composables/use-form-fields/use-form-fields.ts +++ b/app/src/composables/use-form-fields/use-form-fields.ts @@ -5,7 +5,7 @@ import getDefaultInterfaceForType from '@/utils/get-default-interface-for-type'; import { getInterfaces } from '@/interfaces'; import { FormField } from '@/components/v-form/types'; import { Field } from '@/types'; -import { clone, orderBy } from 'lodash'; +import { clone } from 'lodash'; export default function useFormFields(fields: Ref) { const interfaces = getInterfaces(); @@ -13,9 +13,6 @@ export default function useFormFields(fields: Ref) { const formFields = computed(() => { let formFields = clone(fields.value); - // Sort the fields on the sort column value - formFields = orderBy(formFields, [(o) => o.meta?.sort || null, (o) => o.meta?.id]); - formFields = formFields.map((field, index) => { if (!field.meta) return field; diff --git a/app/src/stores/fields.ts b/app/src/stores/fields.ts index 5e37457862..074cae5b98 100644 --- a/app/src/stores/fields.ts +++ b/app/src/stores/fields.ts @@ -6,7 +6,7 @@ import { i18n } from '@/lang'; import formatTitle from '@directus/format-title'; import { useRelationsStore } from '@/stores/'; import { Relation, FieldRaw, Field } from '@/types'; -import { merge } from 'lodash'; +import { merge, orderBy } from 'lodash'; import { nanoid } from 'nanoid'; import { unexpectedError } from '@/utils/unexpected-error'; @@ -221,7 +221,10 @@ export const useFieldsStore = createStore({ return primaryKeyField; }, getFieldsForCollection(collection: string): Field[] { - return this.state.fields.filter((field) => field.collection === collection); + return orderBy( + this.state.fields.filter((field) => field.collection === collection), + (collection) => (collection.meta?.sort ? Number(collection.meta?.sort) : null) + ); }, getFieldsForCollectionAlphabetical(collection: string): Field[] { return this.getFieldsForCollection(collection).sort((a: Field, b: Field) => {