fixes crash when options was empty

This commit is contained in:
Keviin Åberg Kultalahti 2021-02-15 13:31:16 +01:00
parent 17e4ff1c60
commit 9b13879b27
1 changed files with 4 additions and 7 deletions

View File

@ -20,10 +20,9 @@
const setFieldText = (value) => {
if (fieldSchema?.oneToMany) {
if (value?.length) {
const row = options.find(row => row._id === value)
if (!row) return placeholder || 'Choose an option'
return getDisplayName(row)
if (value?.length && options?.length) {
const row = options.find(row => row._id === value[0])
return row.name
} else {
return placeholder || 'Choose an option'
}
@ -36,9 +35,7 @@
}
}
$: console.log(placeholder)
$: fieldText = setFieldText($fieldState?.value)
$: options, fieldText = setFieldText($fieldState?.value)
$: valueLookupMap = getValueLookupMap($fieldState?.value)
$: isOptionSelected = option => valueLookupMap[option] === true
$: linkedTableId = fieldSchema?.tableId