{"record":{"id":"87b5af1534a59995","repo":"facebook/lexical","slug":"cell-not-found-at-cords","errorCode":null,"errorMessage":"Cell not found at cords.","messagePattern":"Cell not found at cords\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/lexical-table/src/LexicalTableNode.ts","lineNumber":757,"sourceCode":"\n    const cell = row[index];\n\n    if (cell == null) {\n      return null;\n    }\n\n    return cell;\n  }\n\n  getDOMCellFromCordsOrThrow(\n    x: number,\n    y: number,\n    table: TableDOMTable,\n  ): TableDOMCell {\n    const cell = this.getDOMCellFromCords(x, y, table);\n\n    if (!cell) {\n      throw new Error('Cell not found at cords.');\n    }\n\n    return cell;\n  }\n\n  getCellNodeFromCords(\n    x: number,\n    y: number,\n    table: TableDOMTable,\n  ): null | TableCellNode {\n    const cell = this.getDOMCellFromCords(x, y, table);\n\n    if (cell == null) {\n      return null;\n    }\n\n    const node = $getNearestNodeFromDOMNode(cell.elem);\n","sourceCodeStart":739,"sourceCodeEnd":775,"githubUrl":"https://github.com/facebook/lexical/blob/76a22dcba981b46119fcec45f935270707e26a57/packages/lexical-table/src/LexicalTableNode.ts#L739-L775","documentation":"This method (getDOMCellOrThrow-style accessor) delegates to getDOMCellFromCords and throws 'Cell not found at cords.' when the coordinate lookup returns null — i.e. the given x/y does not point at a real cell in the DOM table representation. Coordinates outside the table bounds, or a DOM table snapshot that no longer matches the node tree, produce this error.","triggerScenarios":"Calling it with x/y beyond the table's row/column count; passing a TableDOMTable captured before rows/columns were removed by another update; mouse handlers computing coordinates from stale DOM rects.","commonSituations":"Custom table selection plugins doing hit-testing at table edges; drag handlers firing after a column/row deletion re-rendered the table; off-by-one coordinates from getBoundingClientRect math.","solutions":["Clamp/validate x and y against table.getCordsFromCell / table size before lookup","Re-read the DOM table (table.getDOMCellFromCords with a fresh TableDOMTable) inside the current update","Null-check via getDOMCellFromCords directly instead of the throwing wrapper when out-of-bounds is expected"],"exampleFix":"// before\nconst cell = table.getDOMCellAtCords(x, y, domTable); // throws at edges\n\n// after\nconst cell = table.getDOMCellFromCords(x, y, domTable);\nif (cell) { /* handle */ } else { /* outside table: ignore */ }","handlingStrategy":"validation","validationCode":"const rows = table.getRowCount(); // or derive from domTable\nif (x < 0 || y < 0 || x >= columns || y >= rows) return; // outside table\nconst cell = table.getDOMCellFromCords(x, y, domTable); // null-checked instead of throwing","typeGuard":"function cellAt(domTable: TableDOMTable, x: number, y: number): TableDOMCell | null {\n  return domTable.rows[y]?.cells?.[x] ?? null;\n}","tryCatchPattern":"try {\n  const cell = table.getDOMCellAtCords(x, y, domTable);\n} catch (e) {\n  if (String(e).includes('Cell not found at cords')) {\n    // coordinates outside table or stale DOM snapshot — recompute\n  } else { throw e; }\n}","preventionTips":["Use the non-throwing getDOMCellFromCords when out-of-range is a normal case","Recompute TableDOMTable inside the event's update, never cache it","Clamp hit-test coordinates from mouse math to table bounds"],"tags":["lexical","table","coordinates","dom"],"backgroundTag":"cell-not-found-in-table","analyzedSha":"76a22dcba981b46119fcec45f935270707e26a57","analyzedAt":"2026-08-31T21:45:54.792Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}