From 40559d7017cb40f239330fec23724e6531fac427 Mon Sep 17 00:00:00 2001 From: ismay Date: Tue, 18 Jul 2023 12:14:24 +0200 Subject: [PATCH] fix(transfer): ensure selected is an array --- components/transfer/src/transfer.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/components/transfer/src/transfer.js b/components/transfer/src/transfer.js index a36a9c5f43..deca9a9f9f 100644 --- a/components/transfer/src/transfer.js +++ b/components/transfer/src/transfer.js @@ -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: