Skip to content

Commit

Permalink
Fix select all in multiselect (#135)
Browse files Browse the repository at this point in the history
* fix

* cleane

* review

---------

Co-authored-by: Aleksej Tre <[email protected]>
  • Loading branch information
TipTipple and Aleksej Tre committed Jul 5, 2023
1 parent 32f611c commit e36264a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cadolabs/sphere-ui",
"version": "5.0.0",
"version": "5.0.1",
"main": "dist/index.js",
"license": "MIT",
"repository": "https://github.com/Cado-Labs/sphere-ui",
Expand Down
19 changes: 13 additions & 6 deletions src/components/MultiSelect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,19 @@ export const MultiSelect = React.forwardRef(({
}

const handleSelectAll = () => {
const newValue = options.map(option => {
if (optionValue) return option[optionValue]
if (option.hasOwnProperty("value")) return option.value
return option
})

const prepareOptions = options => options.map(option => {
if (optionValue) {
return option[optionValue]
} else if (option.hasOwnProperty("value")) {
return option.value
} else if (option.items) {
return prepareOptions(option.items)
} else {
return option
}
}).flat()

const newValue = prepareOptions(options)
onFooterButtonClick(newValue)
}

Expand Down

0 comments on commit e36264a

Please sign in to comment.