Skip to content

Commit

Permalink
Merge pull request #775 from bartbutenaers/clear-dropdown
Browse files Browse the repository at this point in the history
Clear dropdown selection fix
  • Loading branch information
joepavitt authored Apr 18, 2024
2 parents 25c6171 + 7c61532 commit 87981b4
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions ui/src/widgets/ui-dropdown/UIDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,23 @@ export default {
value = [value]
}
// now if this is a single selection, we just need to find the option with the matching value
if (!this.props.multiple) {
value = this.options.find((o) => {
return o.value === value[0]
})
} else {
// this is a multi selection, we need to find all the options with matching values
value = this.options.filter((o) => {
return value.includes(o.value)
})
}
// if we didn't find any matching options, we stop here
if (!value) {
return
// value [] is used to clear the current selection
if (value.length > 0) {
// now if this is a single selection, we just need to find the option with the matching value
if (!this.props.multiple) {
value = this.options.find((o) => {
return o.value === value[0]
})
} else {
// this is a multi selection, we need to find all the options with matching values
value = this.options.filter((o) => {
return value.includes(o.value)
})
}
// if we didn't find any matching options, we stop here (unless value is [])
if (!value) {
return
}
}
// ensure we set our local "value" to match
Expand Down

0 comments on commit 87981b4

Please sign in to comment.