Skip to content

Commit

Permalink
Fix sort issue
Browse files Browse the repository at this point in the history
  • Loading branch information
vineethasok committed Sep 15, 2023
1 parent 1d23fa0 commit c7e46f4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/components/MultiSelect/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,28 @@ const Trigger = forwardRef<HTMLButtonElement, TriggerProps>(
{selectedValues.length > 0 ? (
<BadgeList
as={ReactSortable}
list={selectedValues.map(value => ({ id: value, value, filtered: sortable }))}
list={selectedValues.map(value => ({
id: `multi-select-${id}-${value}`,
value,
filtered: sortable,
}))}
setList={() => null}
onEnd={e => {
const { newDraggableIndex, oldDraggableIndex } = e;
if (
typeof newDraggableIndex === "number" &&
typeof oldDraggableIndex === "number"
typeof oldDraggableIndex === "number" &&
oldDraggableIndex !== newDraggableIndex
) {
const temp = selectedValues[oldDraggableIndex];
selectedValues[oldDraggableIndex] = selectedValues[newDraggableIndex];
selectedValues[newDraggableIndex] = temp;
updateValues([...selectedValues]);
}
}}
revertOnSpill
>
{selectedValues.map((value, index) => {
{selectedValues.map(value => {
const nodeProps = getValueProps(value);
let otherProps: BadgeProps = {
text: nodeProps.children,
Expand All @@ -220,7 +226,7 @@ const Trigger = forwardRef<HTMLButtonElement, TriggerProps>(
} as DismissibleBadge;
}
return (
<div key={`multi-select-${id}-${index}`}>
<div key={`multi-select-${id}-${value}`}>
<Badge
size="sm"
state={disabled ? "disabled" : "default"}
Expand Down

0 comments on commit c7e46f4

Please sign in to comment.