Skip to content

Commit

Permalink
fix(transfer): ensure selected is an array
Browse files Browse the repository at this point in the history
  • Loading branch information
ismay committed Jul 18, 2023
1 parent 4718b1d commit 40559d7
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions components/transfer/src/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,21 @@ export const Transfer = ({
* Extract the selected options. Can't use `options.filter`
* because we need to keep the order of `selected`
*/
const pickedOptions = actualFilterPickedCallback(
selected
.map((value) => options.find((option) => value === option.value))
// filter -> in case a selected value has been provided
// that does not exist as option
.filter(identity),
actualFilterPicked
)
let pickedOptions = []

// Only map if selected is an array
if (Array.isArray(selected)) {
pickedOptions = actualFilterPickedCallback(
selected
.map((value) =>
options.find((option) => value === option.value)
)
// filter -> in case a selected value has been provided
// that does not exist as option
.filter(identity),
actualFilterPicked
)
}

/*
* Source options highlighting:
Expand Down

0 comments on commit 40559d7

Please sign in to comment.