Fix field tree not updating appropriately. (#9118)

* Fix field tree not updating appropriately.

* Reset visitedRelations on collection change.
This commit is contained in:
Oreille
2021-10-25 17:48:54 +02:00
committed by GitHub
parent bf2b7e8d01
commit b8e54442cb

View File

@@ -27,21 +27,21 @@ export function useFieldTree(
const tree = ref<FieldTree>({});
if (collection.value) {
tree.value = getFieldTreeForCollection(collection.value, 'any');
}
watch(collection, () => {
if (collection.value) {
tree.value = getFieldTreeForCollection(collection.value, 'any');
}
});
const visitedRelations = ref<string[][]>([]);
Object.values(tree.value).forEach((value) => {
loadFieldRelations(value.field);
});
watch(
collection,
() => {
if (collection.value) {
tree.value = getFieldTreeForCollection(collection.value, 'any');
visitedRelations.value = [];
Object.values(tree.value).forEach((value) => {
loadFieldRelations(value.field);
});
}
},
{ immediate: true }
);
const treeList = computed(() => treeToList(tree.value));