diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/ArrayStaticInputEditor.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/ArrayStaticInputEditor.svelte index 9fb0741075..89bb7f2ad7 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/ArrayStaticInputEditor.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/ArrayStaticInputEditor.svelte @@ -11,7 +11,11 @@ import RefreshDatabaseStudioTable from './RefreshDatabaseStudioTable.svelte' import { isObjectOptionArray, isStringArray } from '$lib/components/multiselect/types' - export let componentInput: StaticInput & { loading?: boolean; expr?: string } + export let componentInput: StaticInput & { + loading?: boolean + expr?: string + isLabeled?: boolean + } export let subFieldType: InputType | undefined = undefined export let selectOptions: StaticOptions['selectOptions'] | undefined = undefined export let id: string | undefined @@ -223,6 +227,7 @@ const newComponentInput = { ...componentInput } newComponentInput.value = items.map((item) => item.value).filter((item) => item != undefined) newComponentInput.expr = JSON.stringify(newComponentInput.value) + newComponentInput.isLabeled = labeled const newSubFieldType = labeled ? 'labeledselect' : 'simplestringselect' @@ -281,7 +286,7 @@ {#if hasLabeledMode} | undefined + export let componentInput: (StaticInput & { isLabeled?: boolean }) | undefined export let fieldType: InputType | undefined = undefined export let subFieldType: InputType | undefined = undefined export let selectOptions: StaticOptions['selectOptions'] | undefined = undefined @@ -35,6 +35,18 @@ const { onchange } = getContext('AppViewerContext') + $: componentInput && onchange?.() + + onMount(() => { + /** preserve the `labeled` toggling when switching from eval to static */ + if ( + componentInput?.isLabeled && + fieldType === 'array' && + subFieldType === 'simplestringselect' + ) { + subFieldType = 'labeledselect' + } + }) /** * Workaround for MultiSelect * @@ -49,12 +61,9 @@ return } const { newComponentInput, newSubFieldType } = newData - componentInput = { ...componentInput, ...newComponentInput } subFieldType = newSubFieldType } - - $: componentInput && onchange?.() {#key subFieldType}