Skip to content

Commit

Permalink
fix memoized render when no callback is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
bsholmes committed Dec 22, 2023
1 parent cd5d4cc commit ff644f3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/Table/GridTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,13 @@ export function GridTable<R extends Kinded, X extends Only<GridTableXss, X> = an
// Get the flat list or rows from the header down...
visibleRows.forEach((rs) => {
// only pass through events if the row is draggable and the user has provided a callback
const dragEventHandler = (callback: OnRowDragEvent<R> | undefined) => (evt: DragEventType) => {
if (rs.row.draggable && droppedCallback && callback) {
callback({ ...rs.row }, evt);
}
const dragEventHandler = (callback: OnRowDragEvent<R> | undefined) => {
return rs.row.draggable && callback ?
(evt: DragEventType) => {
if (rs.row.draggable && droppedCallback && callback) {
callback({ ...rs.row }, evt);
}
} : undefined
};

const onDragStart = (row: GridDataRow<R>, evt: DragEventType) => {
Expand Down

0 comments on commit ff644f3

Please sign in to comment.