Skip to content

Commit

Permalink
feat: select freeform option by default in multiselect ComboBox
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Sobolewski committed Sep 13, 2023
1 parent 6608a73 commit 52fb740
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/src/inputs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ function handleMultiSelect(option, selectedKeys, propsOptions) {
const options = new Set(propsOptions.map((item) => item.key));
let currentSelectedOptionKeys = (Array.isArray(selectedKeys) ? selectedKeys : [selectedKeys])
.filter((key) => options.has(key)); // Some options might have been removed.
currentSelectedOptionKeys = option.selected
// If option doesn't have selected property it comes from freeform, so it's selected by default.
const selected = option.selected ?? true;
currentSelectedOptionKeys = selected
? [...currentSelectedOptionKeys, option.key]
: currentSelectedOptionKeys.filter((key) => key !== option.key);
return currentSelectedOptionKeys;
Expand Down

0 comments on commit 52fb740

Please sign in to comment.