{"record":{"id":"aadea3d93317b837","repo":"facebook/lexical","slug":"cell-not-found-in-table","errorCode":null,"errorMessage":"Cell not found in table.","messagePattern":"Cell not found in table\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/lexical-table/src/LexicalTableNode.ts","lineNumber":722,"sourceCode":"\n      if (row == null) {\n        continue;\n      }\n\n      for (let x = 0; x < row.length; x++) {\n        const cell = row[x];\n        if (cell == null) {\n          continue;\n        }\n        const {elem} = cell;\n        const cellNode = $getNearestTableCellInTableFromDOMNode(this, elem);\n        if (cellNode !== null && tableCellNode.is(cellNode)) {\n          return {x, y};\n        }\n      }\n    }\n\n    throw new Error('Cell not found in table.');\n  }\n\n  getDOMCellFromCords(\n    x: number,\n    y: number,\n    table: TableDOMTable,\n  ): null | TableDOMCell {\n    const {domRows} = table;\n\n    const row = domRows[y];\n\n    if (row == null) {\n      return null;\n    }\n\n    const index = x < row.length ? x : row.length - 1;\n\n    const cell = row[index];","sourceCodeStart":704,"sourceCodeEnd":740,"githubUrl":"https://github.com/facebook/lexical/blob/76a22dcba981b46119fcec45f935270707e26a57/packages/lexical-table/src/LexicalTableNode.ts#L704-L740","documentation":"TableNode.getCordsFromCell (or the method containing this throw) converts a TableCellNode into (x, y) coordinates by scanning the table's rows/cells; when the given cell is not found anywhere in the table it throws 'Cell not found in table.'. This means the caller passed a TableCellNode that is not a descendant of this TableNode, or the table's cached structure is stale.","triggerScenarios":"Calling getCordsFromCell(tableCellNode) on a TableNode while passing a cell that belongs to a different table, a detached cell, or a cell whose parent linkage was mutated mid-update.","commonSituations":"Selection code iterating cells across table boundaries; custom plugins storing TableCellNode references across update boundaries (stale keys resolve incorrectly); mergeCells/insert operations running transforms that detach the cell before coordinate lookup.","solutions":["Confirm the TableCellNode is actually a descendant of this TableNode (walk parents via $isParentElement before the call)","Re-read the cell inside the same update context instead of reusing cached node references","Look up the cell through the selection or DOM cell (getDOMCellFromCords) rather than assuming membership"],"exampleFix":"// before\nconst cell = $getNodeByKey(someKey);\ntable.getCordsFromCell(cell); // throws if cell not in this table\n\n// after\nconst cell = $getNodeByKey(someKey);\nif ($isTableCellNode(cell) && cell.getParentOrThrow().getParentOrThrow().is(table)) {\n  const {x, y} = table.getCordsFromCell(cell);\n}","handlingStrategy":"type-guard","validationCode":"function isCellInTable(table: TableNode, cell: LexicalNode | null | undefined): boolean {\n  let parent = cell?.getParent();\n  while (parent) {\n    if (parent.is(table)) return true;\n    parent = parent.getParent();\n  }\n  return false;\n}\n// guard: if (!isCellInTable(table, cellNode)) return;","typeGuard":"function isTableCellOf(node: LexicalNode | null, table: TableNode): node is TableCellNode {\n  return $isTableCellNode(node) && isCellInTable(table, node);\n}","tryCatchPattern":"try {\n  const {x, y} = table.getCordsFromCell(cellNode);\n} catch (e) {\n  if (String(e).includes('Cell not found in table')) {\n    // cell belongs to another/detached table — re-resolve within current update\n  } else { throw e; }\n}","preventionTips":["Never cache TableCellNode references across editor.update boundaries","Verify parent chain membership before coordinate lookups","Do all table cell geometry inside a single update/read block"],"tags":["lexical","table","coordinates","node-tree"],"backgroundTag":"cell-not-found-in-table","analyzedSha":"76a22dcba981b46119fcec45f935270707e26a57","analyzedAt":"2026-08-31T21:45:54.792Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}