From 9a891cef8c42d3f86d45f6ef7e85fdb766db3f7d Mon Sep 17 00:00:00 2001 From: Mitchell Hamilton Date: Thu, 1 Jul 2021 14:39:29 +1000 Subject: [PATCH] Fix relationship fields with `displayMode: 'cards'` not using labels in the Cell component (#6041) --- .changeset/wise-news-share.md | 5 +++++ packages-next/fields/src/types/relationship/index.ts | 1 + packages-next/fields/src/types/relationship/views/index.tsx | 2 ++ 3 files changed, 8 insertions(+) create mode 100644 .changeset/wise-news-share.md diff --git a/.changeset/wise-news-share.md b/.changeset/wise-news-share.md new file mode 100644 index 00000000000..a71ae28ce31 --- /dev/null +++ b/.changeset/wise-news-share.md @@ -0,0 +1,5 @@ +--- +'@keystone-next/fields': patch +--- + +Fixed `relationship` field with `displayMode: 'cards'` not using labels for related items in the cell view. diff --git a/packages-next/fields/src/types/relationship/index.ts b/packages-next/fields/src/types/relationship/index.ts index 2ced5b3360d..81bdad13700 100644 --- a/packages-next/fields/src/types/relationship/index.ts +++ b/packages-next/fields/src/types/relationship/index.ts @@ -97,6 +97,7 @@ export const relationship = inlineCreate: config.ui.inlineCreate ?? null, inlineEdit: config.ui.inlineEdit ?? null, inlineConnect: config.ui.inlineConnect ?? false, + refLabelField: adminMetaRoot.listsByKey[foreignListKey].labelField, } : config.ui?.displayMode === 'count' ? { displayMode: 'count' } diff --git a/packages-next/fields/src/types/relationship/views/index.tsx b/packages-next/fields/src/types/relationship/views/index.tsx index f690712ee5f..2a1e8a09b85 100644 --- a/packages-next/fields/src/types/relationship/views/index.tsx +++ b/packages-next/fields/src/types/relationship/views/index.tsx @@ -384,6 +384,7 @@ export const controller = ( inlineCreate: { fields: string[] } | null; inlineEdit: { fields: string[] } | null; inlineConnect: boolean; + refLabelField: string; } | { displayMode: 'count' } ) @@ -418,6 +419,7 @@ export const controller = ( `${config.path}__id: id ${config.path} { id + label: ${config.fieldMeta.refLabelField} }` : config.fieldMeta.displayMode === 'count' ? `_${config.path}Meta {count}`