Skip to content

Commit

Permalink
[core] fix order of new columns when calling updateColumns
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffrey Hervet committed May 17, 2024
1 parent fc54a8b commit afc0a85
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,18 @@ export const createColumnsState = ({
});

if (columnsState.desiredOrderedFields) {
columnsState.orderedFields.sort((fieldA, fieldB) =>
columnsState.desiredOrderedFields!.indexOf(fieldA) - columnsState.desiredOrderedFields!.indexOf(fieldB)
);
columnsState.orderedFields.sort((fieldA, fieldB) => {
const indexA = columnsState.desiredOrderedFields!.indexOf(fieldA);
const indexB = columnsState.desiredOrderedFields!.indexOf(fieldB);
if (indexA === -1 && indexB !== -1) {
return 1;
}
if (indexB === -1 && indexA !== -1) {
return -1;
}

return indexA - indexB
});

delete columnsState.desiredOrderedFields;
}
Expand Down

0 comments on commit afc0a85

Please sign in to comment.