Skip to content

Commit

Permalink
[Fix] Fix console error when dragging to reorder columns
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Sep 21, 2021
1 parent b23c9d7 commit 6be8f53
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/components/datagrid/column_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ export const useDataGridColumnSelector = (
source: { index: sourceIndex },
destination,
}: DropResult) {
const destinationIndex = destination!.index;
const nextSortedColumns = euiDragDropReorder(
sortedColumns,
sourceIndex,
destinationIndex
);
setColumns(nextSortedColumns);
if (destination) {
const destinationIndex = destination.index;
const nextSortedColumns = euiDragDropReorder(
sortedColumns,
sourceIndex,
destinationIndex
);
setColumns(nextSortedColumns);
}
}

const numberOfHiddenFields = availableColumns.length - visibleColumns.length;
Expand Down

0 comments on commit 6be8f53

Please sign in to comment.