From d4a556d0f66936f4e0acedb5c10c4875509716ff Mon Sep 17 00:00:00 2001 From: Clement Zhang Date: Fri, 8 Nov 2024 11:26:42 +0100 Subject: [PATCH] multiselect: keep defaultItems (no breaking change) --- .../apps/components/inputs/AppMultiSelect.svelte | 8 ++++---- .../apps/components/inputs/AppMultiSelectV2.svelte | 4 ++-- .../lib/components/apps/editor/component/components.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/src/lib/components/apps/components/inputs/AppMultiSelect.svelte b/frontend/src/lib/components/apps/components/inputs/AppMultiSelect.svelte index f6686b9a9b..7b75d6391e 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppMultiSelect.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppMultiSelect.svelte @@ -60,11 +60,11 @@ } } - $: resolvedConfig.defaultValues && handleDefaultValues() + $: resolvedConfig.defaultItems && handleDefaultItems() - function handleDefaultValues() { - if (Array.isArray(resolvedConfig.defaultValues)) { - const nvalue = resolvedConfig.defaultValues?.map((label) => { + function handleDefaultItems() { + if (Array.isArray(resolvedConfig.defaultItems)) { + const nvalue = resolvedConfig.defaultItems?.map((label) => { return typeof label === 'string' ? label : `NOT_STRING` }) value = [...new Set(nvalue)] diff --git a/frontend/src/lib/components/apps/components/inputs/AppMultiSelectV2.svelte b/frontend/src/lib/components/apps/components/inputs/AppMultiSelectV2.svelte index e5c99d4996..852d9603a1 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppMultiSelectV2.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppMultiSelectV2.svelte @@ -57,8 +57,8 @@ } } - $: if (resolvedConfig.defaultValues) { - selectOptionsByValue(resolvedConfig.defaultValues) + $: if (resolvedConfig.defaultItems) { + selectOptionsByValue(resolvedConfig.defaultItems) } $: outerDiv && diff --git a/frontend/src/lib/components/apps/editor/component/components.ts b/frontend/src/lib/components/apps/editor/component/components.ts index 3ac23aad6c..9f6f6a2994 100644 --- a/frontend/src/lib/components/apps/editor/component/components.ts +++ b/frontend/src/lib/components/apps/editor/component/components.ts @@ -2151,7 +2151,7 @@ This is a paragraph. subFieldType: 'text', value: ['Foo', 'Bar'] } as StaticAppInput, - defaultValues: { + defaultItems: { type: 'static', fieldType: 'array', subFieldType: 'text', @@ -2204,7 +2204,7 @@ This is a paragraph. value: ['Foo', 'Bar'], hasLabeledMode: true } as StaticAppInput, - defaultValues: { + defaultItems: { type: 'static', fieldType: 'array', subFieldType: 'simplestringselect',