Description
Dragging a column header in InfiniteTable throws an uncaught TypeError every time. The error fires inside the library's own drag event handler — no user code is involved in the crash path.
Error
TypeError: Cannot read properties of undefined (reading 'getAttribute')
at @infinite-table_infinite-react.js:5570:94
at @infinite-table_infinite-react.js:8476:9
at executeDispatch (react-dom-client.js:9141:5)
at runWithFiberInDEV (react-dom-client.js:851:66)
at processDispatchQueue (react-dom-client.js:9167:27)
at react-dom-client.js:9454:5
at batchedUpdates$1 (react-dom-client.js:2044:12)
at dispatchEventForPluginEventSystem (react-dom-client.js:9240:4)
at dispatchEvent (react-dom-client.js:11319:29)
at dispatchDiscreteEvent (react-dom-client.js:11301:56)
Root cause (found in index.dev.mjs)
In onDragItemPointerDown (~line 8858 of index.dev.mjs), after finding the drag item ID from the event target, the code does:
const dragIndex = draggableItems.findIndex(
(item) => item.id === dragItemId2
);
// dragIndex can be -1 if the dragged column is not found in draggableItems
const dragItem = draggableItems[dragIndex];
const dragItemNode = dragItems[dragIndex].getAttribute(DRAG_ITEM_ATTRIBUTE) // CRASH: dragItems[-1] is undefined
=== `${dragItemId2}`
? dragItems[dragIndex]
: dragItems.find(
(node) => node.getAttribute(DRAG_ITEM_ATTRIBUTE) === `${dragItemId2}`
);
When findIndex returns -1 (the dragged column is not found in draggableItems), dragItems[-1] is undefined and calling .getAttribute() on it throws.
There is no null/bounds check before accessing dragItems[dragIndex].
Fix
Add a guard before the dragItems[dragIndex] access:
const dragIndex = draggableItems.findIndex(
(item) => item.id === dragItemId2
);
if (dragIndex === -1) return; // ← guard missing
const dragItemNode = dragItems[dragIndex].getAttribute(...);
Versions
@infinite-table/infinite-react: 8.0.3 and 8.0.4 (both affected)
- React: 19
- Reproduced with: column drag in InfiniteTable with
onColumnOrderChange wired
Notes
- The error is dispatched via React's discrete event system (
dispatchDiscreteEvent) so it is not catchable by a React ErrorBoundary
- It appears on every column drag attempt, not intermittently
startTransition on the onColumnOrderChange handler does not prevent the crash
Description
Dragging a column header in InfiniteTable throws an uncaught
TypeErrorevery time. The error fires inside the library's own drag event handler — no user code is involved in the crash path.Error
Root cause (found in
index.dev.mjs)In
onDragItemPointerDown(~line 8858 ofindex.dev.mjs), after finding the drag item ID from the event target, the code does:When
findIndexreturns-1(the dragged column is not found indraggableItems),dragItems[-1]isundefinedand calling.getAttribute()on it throws.There is no null/bounds check before accessing
dragItems[dragIndex].Fix
Add a guard before the
dragItems[dragIndex]access:Versions
@infinite-table/infinite-react: 8.0.3 and 8.0.4 (both affected)onColumnOrderChangewiredNotes
dispatchDiscreteEvent) so it is not catchable by a React ErrorBoundarystartTransitionon theonColumnOrderChangehandler does not prevent the crash