1
0
Fork 0
mirror of synced 2024-07-01 20:41:03 +12:00

Refactor for multiselect value parsing and a fix to ensure default values are parsed before reaching the picker

This commit is contained in:
Dean 2022-10-18 11:06:18 +01:00
parent a0a9d35b50
commit b31f7f4b87
2 changed files with 15 additions and 10 deletions

View file

@ -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
}, []) }, [])

View file

@ -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