diff --git a/frontend/src/lib/components/apps/components/inputs/AppMultiSelectV2.svelte b/frontend/src/lib/components/apps/components/inputs/AppMultiSelectV2.svelte index ca7bcb0dc5..0c14382987 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppMultiSelectV2.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppMultiSelectV2.svelte @@ -27,8 +27,6 @@ // every option is labeled, or no one is. type Options = ObjectOption[] | string[] - $: resolvedConfig.items && handleItems() - const [floatingRef, floatingContent] = createFloatingActions({ strategy: 'absolute', middleware: [offset(5), flip(), shift()] @@ -43,6 +41,21 @@ configuration ) + $: handleItems(resolvedConfig.items) + + function handleItems(resolvedConfigItems) { + if (!resolvedConfigItems) { + return + } + items = [] + value = [] + if (isObjectOptionArray(resolvedConfigItems)) { + items = parseLabeledItems(resolvedConfigItems) + } else if (isStringArray(resolvedConfigItems)) { + items = parseStringItems(resolvedConfigItems) + } + } + const outputs = initOutput($worldStore, id, { result: isObjectOptionArray(items) ? ([] as ObjectOption[]) @@ -91,12 +104,8 @@ return arr.every((item) => typeof item === 'string') } - function handleLabeledItems() { - if (!Array.isArray(resolvedConfig.items)) { - items = [] - return - } - items = resolvedConfig.items?.map((item) => { + function parseLabeledItems(resolvedConfigItems: ObjectOption[]) { + return resolvedConfigItems?.map((item) => { if (!item || typeof item !== 'object') { console.error( 'When labeled, MultiSelect component items should be an array of { label: string, value: string }.' @@ -114,12 +123,8 @@ }) } - function handleStringItems() { - if (!Array.isArray(resolvedConfig.items)) { - items = [] - return - } - items = resolvedConfig.items?.map((item) => { + function parseStringItems(resolvedConfigItems: string[]) { + return resolvedConfigItems?.map((item) => { if (!item || typeof item !== 'string') { console.error( 'When not labeled, MultiSelect component items should be an array of strings.' @@ -130,14 +135,6 @@ }) } - function handleItems() { - if (isObjectOptionArray(resolvedConfig.items)) { - handleLabeledItems() - } else if (isStringArray(resolvedConfig.items)) { - handleStringItems() - } - } - $: resolvedConfig.defaultItems && handleDefaultItems() // todo @@ -235,7 +232,6 @@ {/each} -
@@ -297,6 +294,7 @@ on:open={multiSelectProps.onOpen} on:close={multiSelectProps.onClose} let:option + id="simplestring-multiselect" > @@ -308,7 +306,7 @@ e.target?.['parentElement']?.dispatchEvent(newe) }} > - {option.label} + {option}
{/if} diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/ArrayStaticInputEditor.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/ArrayStaticInputEditor.svelte index 9fbc63b6f0..60f3091e18 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/ArrayStaticInputEditor.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/ArrayStaticInputEditor.svelte @@ -293,19 +293,6 @@
- {#if Array.isArray(items) && componentInput.value}
{pluralize(items.length, 'item')}
diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/SubTypeEditor.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/SubTypeEditor.svelte index 406059ea40..e1171c56bd 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/SubTypeEditor.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/SubTypeEditor.svelte @@ -16,10 +16,6 @@ $: fakeComponentInput && (value = fakeComponentInput.value) -