Refactor for multiselect value parsing and a fix to ensure default values are parsed before reaching the picker
This commit is contained in:
parent
a0a9d35b50
commit
b31f7f4b87
|
@ -16,16 +16,13 @@
|
||||||
export let autoWidth = false
|
export let autoWidth = false
|
||||||
|
|
||||||
$: streamed = Array.isArray(value)
|
$: streamed = Array.isArray(value)
|
||||||
? value.reduce((acc, ele) => {
|
? value.reduce((acc, entry) => {
|
||||||
if (typeof ele === "string") {
|
if (typeof ele === "string" && entry.trim() === "") {
|
||||||
let temp = ele.trim()
|
return acc
|
||||||
if (!temp) {
|
|
||||||
return acc
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let processedOpt = ele.toString()
|
let processedOption = String(entry)
|
||||||
if (options.indexOf(processedOpt) > -1) {
|
if (options.indexOf(processedOption) > -1) {
|
||||||
acc.push(ele.toString())
|
acc.push(processedOption)
|
||||||
}
|
}
|
||||||
return acc
|
return acc
|
||||||
}, [])
|
}, [])
|
||||||
|
|
|
@ -27,11 +27,19 @@
|
||||||
$: formField = formApi?.registerField(
|
$: formField = formApi?.registerField(
|
||||||
field,
|
field,
|
||||||
type,
|
type,
|
||||||
defaultValue,
|
parseDefaultValue(defaultValue),
|
||||||
disabled,
|
disabled,
|
||||||
validation,
|
validation,
|
||||||
formStep
|
formStep
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const parseDefaultValue = defaultValue => {
|
||||||
|
if (Array.isArray(defaultValue) && type === "array") {
|
||||||
|
return defaultValue.map(val => String(val))
|
||||||
|
}
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
|
||||||
$: schemaType = fieldSchema?.type !== "formula" ? fieldSchema?.type : "string"
|
$: schemaType = fieldSchema?.type !== "formula" ? fieldSchema?.type : "string"
|
||||||
|
|
||||||
// Focus label when editing
|
// Focus label when editing
|
||||||
|
|
Loading…
Reference in New Issue