mirror of
https://github.com/directus/directus.git
synced 2026-02-11 14:05:14 -05:00
Fix issue that would cause sort order of fields to be corrupted on field changes (#6174)
Fixes #6091
This commit is contained in:
@@ -5,12 +5,14 @@ import { getInterfaces } from '@/interfaces';
|
||||
import { InterfaceConfig } from '@/interfaces/types';
|
||||
import { Field } from '@/types';
|
||||
import { getDefaultInterfaceForType } from '@/utils/get-default-interface-for-type';
|
||||
import { clone } from 'lodash';
|
||||
import { clone, orderBy } from 'lodash';
|
||||
import { computed, ComputedRef, Ref } from 'vue';
|
||||
|
||||
export default function useFormFields(fields: Ref<Field[]>): { formFields: ComputedRef<Field[]> } {
|
||||
const { interfaces } = getInterfaces();
|
||||
|
||||
const systemFieldsCount = computed(() => fields.value.filter((field) => field.meta?.system === true).length);
|
||||
|
||||
const formFields = computed(() => {
|
||||
let formFields = clone(fields.value);
|
||||
|
||||
@@ -42,6 +44,10 @@ export default function useFormFields(fields: Ref<Field[]>): { formFields: Compu
|
||||
}
|
||||
}
|
||||
|
||||
if (field.meta?.sort && field.meta?.system !== true) {
|
||||
field.meta.sort = field.meta.sort + systemFieldsCount.value;
|
||||
}
|
||||
|
||||
return field;
|
||||
});
|
||||
|
||||
@@ -52,6 +58,8 @@ export default function useFormFields(fields: Ref<Field[]>): { formFields: Compu
|
||||
return hidden !== true && systemFake === false;
|
||||
});
|
||||
|
||||
formFields = orderBy(formFields, 'meta.sort');
|
||||
|
||||
return formFields;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user