mirror of
https://github.com/directus/directus.git
synced 2026-01-26 21:28:11 -05:00
Fix field configuration view not updating when navigating between different fields in New Field drawer (#17254)
* Fix field configuration view not updating when navigating between different fields in New Field drawer * Used Vue toRef instead of computed as per the feedback * Make type reactive too Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -4,16 +4,13 @@ import { useExtensions } from '@/extensions';
|
||||
import { pluralize } from '@directus/shared/utils';
|
||||
|
||||
export function useExtension<T extends AppExtensionType | HybridExtensionType>(
|
||||
type: T,
|
||||
type: T | Ref<T>,
|
||||
name: string | Ref<string | null>
|
||||
): Ref<AppExtensionConfigs[Plural<T>][number] | null> {
|
||||
const extensions = useExtensions();
|
||||
|
||||
return computed(() => {
|
||||
const nameRaw = unref(name);
|
||||
|
||||
if (nameRaw === null) return null;
|
||||
|
||||
return (extensions[pluralize(type)].value as any[]).find(({ id }) => id === nameRaw) ?? null;
|
||||
if (unref(name) === null) return null;
|
||||
return (extensions[pluralize(unref(type))].value as any[]).find(({ id }) => id === unref(name)) ?? null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
import { defineComponent, PropType, computed, toRefs } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useFieldDetailStore } from '../store';
|
||||
import { storeToRefs } from 'pinia';
|
||||
@@ -69,8 +69,9 @@ export default defineComponent({
|
||||
const fieldDetailStore = useFieldDetailStore();
|
||||
|
||||
const { collection, field } = storeToRefs(fieldDetailStore);
|
||||
const { extension, type } = toRefs(props);
|
||||
|
||||
const extensionInfo = useExtension(props.type, props.extension);
|
||||
const extensionInfo = useExtension(type, extension);
|
||||
|
||||
const usesCustomComponent = computed(() => {
|
||||
if (!extensionInfo.value) return false;
|
||||
|
||||
Reference in New Issue
Block a user