Unify selectedValue func

This commit is contained in:
Adria Navarro 2023-09-22 10:14:17 +02:00
parent 013f00e90d
commit 06d881aa7f
1 changed files with 4 additions and 3 deletions

View File

@ -39,8 +39,9 @@
$: options = $fetch.rows
$: tableDefinition = $fetch.definition
$: singleValue = flatten(fieldState?.value)?.[0]
$: multiValue = flatten(fieldState?.value) ?? []
$: selectedValue = multiselect
? flatten(fieldState?.value) ?? []
: flatten(fieldState?.value)?.[0]
$: component = multiselect ? CoreMultiselect : CoreSelect
$: expandedDefaultValue = expand(defaultValue)
$: primaryDisplay = tableDefinition?.primaryDisplay || "_id"
@ -121,7 +122,7 @@
this={component}
{options}
{autocomplete}
value={multiselect ? multiValue : singleValue}
value={selectedValue}
on:change={multiselect ? multiHandler : singleHandler}
id={fieldState.fieldId}
disabled={fieldState.disabled}