Skip to content

Commit

Permalink
fix: draggable grouping shouldn't throw error when dynamically changi…
Browse files Browse the repository at this point in the history
…ng columns (#922)

- get latest reorderedColumns on each end event handler
  • Loading branch information
dmitov92 authored Mar 3, 2023
1 parent 8d61aa5 commit 07a39dc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/common/src/extensions/slickDraggableGrouping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ export class SlickDraggableGrouping {
* @param trigger - callback to execute when triggering a column grouping
*/
setupColumnReorder(grid: SlickGrid, headers: any, _headerColumnWidthDiff: any, setColumns: (columns: Column[]) => void, setupColumnResize: () => void, columns: Column[], getColumnIndex: (columnId: string) => number, uid: string, trigger: (slickEvent: SlickEvent, data?: any) => void) {
let reorderedColumns = grid.getColumns();
const dropzoneElm = grid.getPreHeaderPanel();
const draggablePlaceholderElm = dropzoneElm.querySelector<HTMLDivElement>('.slick-draggable-dropzone-placeholder');
const groupTogglerElm = dropzoneElm.querySelector<HTMLDivElement>('.slick-group-toggle-all');
Expand Down Expand Up @@ -352,14 +351,14 @@ export class SlickDraggableGrouping {
}

const finalReorderedColumns: Column[] = [];
const reorderedColumns = grid.getColumns();
for (const reorderedId of reorderedIds) {
finalReorderedColumns.push(reorderedColumns[getColumnIndex(reorderedId)]);
}
setColumns(finalReorderedColumns);
trigger(grid.onColumnsReordered, { grid });
e.stopPropagation();
setupColumnResize();
reorderedColumns = finalReorderedColumns;
}
} as SortableOptions;

Expand Down Expand Up @@ -632,4 +631,4 @@ export class SlickDraggableGrouping {
}
this.onGroupChanged.notify(args);
}
}
}

0 comments on commit 07a39dc

Please sign in to comment.