Values or defaults passed to the picker are parsed to ensure only valid options are marked/added to the component.

This commit is contained in:
Dean 2022-10-17 12:03:13 +01:00
parent 51ce51078e
commit 8c62ea9833
2 changed files with 20 additions and 4 deletions

View File

@ -15,12 +15,28 @@
export let sort = false
export let autoWidth = false
$: streamed = Array.isArray(value)
? value.reduce((acc, ele) => {
if (typeof ele === "string") {
let temp = ele.trim()
if (!temp) {
return acc
}
}
let processedOpt = ele.toString()
if (options.indexOf(processedOpt) > -1) {
acc.push(ele.toString())
}
return acc
}, [])
: []
const dispatch = createEventDispatcher()
$: selectedLookupMap = getSelectedLookupMap(value)
$: selectedLookupMap = getSelectedLookupMap(streamed)
$: optionLookupMap = getOptionLookupMap(options)
$: fieldText = getFieldText(value, optionLookupMap, placeholder)
$: fieldText = getFieldText(streamed, optionLookupMap, placeholder)
$: isOptionSelected = optionValue => selectedLookupMap[optionValue] === true
$: toggleOption = makeToggleOption(selectedLookupMap, value)
$: toggleOption = makeToggleOption(selectedLookupMap, streamed)
const getFieldText = (value, map, placeholder) => {
if (Array.isArray(value) && value.length > 0) {

View File

@ -247,7 +247,7 @@
return
}
hoverTarget = {
title: binding.display?.name || binding.fieldSchema.name,
title: binding.display?.name || binding.fieldSchema?.name,
description: binding.description,
}
popover.show()