From 5aeb3fa0b74fb0d72f0439ce540baf224654f1ae Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 30 Sep 2025 08:48:28 +0000 Subject: [PATCH] fix: multiselect + jsoneditor nits --- frontend/src/lib/components/ArgInput.svelte | 3 ++- frontend/src/lib/components/ArrayTypeNarrowing.svelte | 2 +- frontend/src/lib/components/JsonEditor.svelte | 6 +++--- frontend/src/lib/components/select/utils.svelte.ts | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/lib/components/ArgInput.svelte b/frontend/src/lib/components/ArgInput.svelte index ace4f6cbed..09940c019b 100644 --- a/frontend/src/lib/components/ArgInput.svelte +++ b/frontend/src/lib/components/ArgInput.svelte @@ -284,7 +284,7 @@ function checkArrayValueType() { try { if (Array.isArray(value) && value.length > 0) { - const firstItem = value?.[0] + let firstItem = value?.[0] const type = itemsType?.type switch (type) { @@ -499,6 +499,7 @@ $effect.pre(() => { !isListJson && inputCat === 'list' && + enum_ == undefined && value != lastValue && itemsType?.type && !hasIsListJsonChanged && diff --git a/frontend/src/lib/components/ArrayTypeNarrowing.svelte b/frontend/src/lib/components/ArrayTypeNarrowing.svelte index 0a27ddf228..8f9f4f537c 100644 --- a/frontend/src/lib/components/ArrayTypeNarrowing.svelte +++ b/frontend/src/lib/components/ArrayTypeNarrowing.svelte @@ -80,7 +80,7 @@ } } items={[ - { value: 'string', label: 'Items are strings' }, + { value: 'string', label: "Items are strings or objects with a 'label/value' field" }, { value: 'enum', label: 'Items are strings from an enum' }, ...(originalType != 'string[]' ? [ diff --git a/frontend/src/lib/components/JsonEditor.svelte b/frontend/src/lib/components/JsonEditor.svelte index b3287b3383..416a3148c3 100644 --- a/frontend/src/lib/components/JsonEditor.svelte +++ b/frontend/src/lib/components/JsonEditor.svelte @@ -4,7 +4,7 @@ import '@codingame/monaco-vscode-standalone-json-language-features' import SimpleEditor from '$lib/components/SimpleEditor.svelte' - import { createEventDispatcher } from 'svelte' + import { createEventDispatcher, untrack } from 'svelte' import { createDispatcherIfMounted } from '$lib/createDispatcherIfMounted' import Button from './common/button/Button.svelte' import { twMerge } from 'tailwind-merge' @@ -55,8 +55,8 @@ error = e.message } } - run(() => { - code != undefined && parseJson() + $effect(() => { + code != undefined && untrack(() => parseJson()) }) diff --git a/frontend/src/lib/components/select/utils.svelte.ts b/frontend/src/lib/components/select/utils.svelte.ts index 4a1f497cca..6527917f49 100644 --- a/frontend/src/lib/components/select/utils.svelte.ts +++ b/frontend/src/lib/components/select/utils.svelte.ts @@ -59,6 +59,7 @@ export function safeSelectItems( list: (T | { value: T; label?: string } | undefined | null)[] | undefined | null ): { value: T; label?: string }[] { if (!list) return [] + if (!Array.isArray(list)) return [] return list .filter((item) => item !== undefined && item !== null) .map((item) => {