fix: multiselect + jsoneditor nits

This commit is contained in:
Ruben Fiszel
2025-09-30 08:48:28 +00:00
parent 53fd4ccb82
commit 5aeb3fa0b7
4 changed files with 7 additions and 5 deletions
+2 -1
View File
@@ -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 &&
@@ -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[]'
? [
@@ -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())
})
</script>
@@ -59,6 +59,7 @@ export function safeSelectItems<T>(
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) => {