Skip to content

Commit

Permalink
Fix Multi select sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
vineethasok committed Sep 24, 2023
1 parent 559b24e commit 76996d5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/components/Select/MultiSelect.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default {
argTypes: {
label: { control: "text" },
disabled: { control: "boolean" },
sortable: { control: "boolean" },
error: { control: "text" },
value: { control: "text" },
defaultValue: { control: "text" },
Expand Down
6 changes: 3 additions & 3 deletions src/components/Select/MultiSelectValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ export const MultiSelectValue = ({
selectedValues.map(value => ({
id: `multi-select-${id}-${value}`,
value,
filtered: sortable,
}))
);
useEffect(() => {
setValues(
selectedValues.map(value => ({
id: `multi-select-${id}-${value}`,
value,
filtered: sortable,
}))
);
}, [id, selectedValues, sortable]);
}, [id, selectedValues]);
if (selectedValues.length === 0) {
return null;
}

return (
<BadgeList
as={ReactSortable}
disabled={!sortable}
list={values}
setList={setValues}
onEnd={e => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Select/common/InternalSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export const InternalSelect = ({
disabled={disabled ?? false}
onSelect={onSelect}
selectedValues={selectedValues}
sortable={sortable ?? false}
sortable={!disabled && sortable}
valueNode={valueNode.current}
onChange={onChange}
/>
Expand Down

0 comments on commit 76996d5

Please sign in to comment.