From 60e3533354ea6438356956720371d8b6bc115007 Mon Sep 17 00:00:00 2001 From: mertmit Date: Sat, 6 Jan 2024 08:47:48 +0000 Subject: [PATCH] fix: handle singular response for user cell --- packages/nc-gui/components/cell/User.vue | 25 ++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/nc-gui/components/cell/User.vue b/packages/nc-gui/components/cell/User.vue index 4025149940..4eac73c484 100644 --- a/packages/nc-gui/components/cell/User.vue +++ b/packages/nc-gui/components/cell/User.vue @@ -27,7 +27,7 @@ import { import MdiCloseCircle from '~icons/mdi/close-circle' interface Props { - modelValue?: UserFieldRecordType[] | string | null + modelValue?: UserFieldRecordType[] | UserFieldRecordType | string | null rowIndex?: number location?: 'cell' | 'filter' forceMulti?: boolean @@ -113,17 +113,18 @@ const vModel = computed({ return acc }, [] as { label: string; value: string }[]) } else { - selected = - modelValue?.reduce((acc, item) => { - const label = item?.display_name || item?.email - if (label) { - acc.push({ - label, - value: item.id, - }) - } - return acc - }, [] as { label: string; value: string }[]) || [] + selected = modelValue + ? (Array.isArray(modelValue) ? modelValue : [modelValue]).reduce((acc, item) => { + const label = item?.display_name || item?.email + if (label) { + acc.push({ + label, + value: item.id, + }) + } + return acc + }, [] as { label: string; value: string }[]) + : [] } return selected