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
|
||||
|
||||
$: streamed = Array.isArray(value)
|
||||
? value.reduce((acc, ele) => {
|
||||
if (typeof ele === "string") {
|
||||
let temp = ele.trim()
|
||||
if (!temp) {
|
||||
return acc
|
||||
}
|
||||
? value.reduce((acc, entry) => {
|
||||
if (typeof ele === "string" && entry.trim() === "") {
|
||||
return acc
|
||||
}
|
||||
let processedOpt = ele.toString()
|
||||
if (options.indexOf(processedOpt) > -1) {
|
||||
acc.push(ele.toString())
|
||||
let processedOption = String(entry)
|
||||
if (options.indexOf(processedOption) > -1) {
|
||||
acc.push(processedOption)
|
||||
}
|
||||
return acc
|
||||
}, [])
|
||||
|
|
|
@ -27,11 +27,19 @@
|
|||
$: formField = formApi?.registerField(
|
||||
field,
|
||||
type,
|
||||
defaultValue,
|
||||
parseDefaultValue(defaultValue),
|
||||
disabled,
|
||||
validation,
|
||||
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"
|
||||
|
||||
// Focus label when editing
|
||||
|
|
Loading…
Reference in New Issue