Skip to content

TypeError: Cannot read properties of undefined (reading 'getAttribute') on column drag #288

Closed

Description

@marynaozirska

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

Activity

  1. radubrehar commented on Jul 6, 2026

    @radubrehar
    Contributor

    thanks for reporting, we're fixing it and will publish a patch very soon

  2. self-assigned this
    on Jul 6, 2026
  3. radubrehar commented on Jul 6, 2026

    @radubrehar
    Contributor

    Should be fixed in 8.0.5

  4. radubrehar commented on Sep 3, 2026

    @radubrehar
    Contributor

    @marynaozirska did 8.0.5 fix it for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions