From 48a85ae10395fc3d67d048a33f5d7aca198914da Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 16 Apr 2021 11:32:05 +0100 Subject: [PATCH] Improve multiselect determintation of pretty labels --- packages/bbui/src/Form/Core/Multiselect.svelte | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/bbui/src/Form/Core/Multiselect.svelte b/packages/bbui/src/Form/Core/Multiselect.svelte index 96733ec454..90fdfaaa48 100644 --- a/packages/bbui/src/Form/Core/Multiselect.svelte +++ b/packages/bbui/src/Form/Core/Multiselect.svelte @@ -20,7 +20,10 @@ const getFieldText = (value, map, placeholder) => { if (value?.length) { - const vals = value.map(option => map[option] || "").join(", ") + if (!map) { + return "" + } + const vals = value.map(option => map[option] || option).join(", ") return `(${value.length}) ${vals}` } else { return placeholder || "Choose some options" @@ -40,8 +43,9 @@ } const getOptionLookupMap = options => { - let map = {} - if (options) { + let map = null + if (options?.length) { + map = {} options.forEach(option => { const optionValue = getOptionValue(option) if (optionValue != null) {