1
0
Fork 0
mirror of synced 2024-09-28 07:11:40 +12:00

Merge pull request #12861 from Budibase/fix/compare-select-issue

Quick fix for Select compare functionality
This commit is contained in:
Michael Drury 2024-01-24 16:35:32 +00:00 committed by GitHub
commit a8c5588f15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,7 +12,7 @@
export let getOptionIcon = () => null
export let getOptionColour = () => null
export let getOptionSubtitle = () => null
export let compare = (option, value) => option === value
export let compare = null
export let useOptionIconImage = false
export let isOptionEnabled
export let readonly = false
@ -40,9 +40,10 @@
if (!options?.length) {
return ""
}
const index = options.findIndex((option, idx) =>
compare(getOptionValue(option, idx), value)
)
const index = options.findIndex((option, idx) => {
const opt = getOptionValue(option, idx)
return typeof compare === "function" ? compare(opt, value) : opt === value
})
return index !== -1 ? getAttribute(options[index], index) : null
}