Fix table/editor clicks on unmapped contentEditable regions so typing or paste cannot desync DOM from Slate or crash toSlateRange.
- Clicking editor padding/unmapped regions with table content does not leave a stale invalid interaction path.
- Targeted regression coverage proves the selection recovery contract.
- Browser check proves
/docs/tableno longer throws in the reported flow.
- Fetch issue, discussion, comments, and prior local learnings.
- Classify scope and release requirement.
- Add failing regression coverage for unmapped table click handling.
- Implement the highest-leverage fix.
- Run package verification and lint.
- Run browser verification on
/docs/table. - Create changeset.
- Run PR gate.
- Create PR and issue comment.
- The issue is real table/browser behavior: root/padding/gap clicks can leave
editor.selectionstale, then typing or rich paste can hit an unmapped DOM point. - Discussion says suppressing
toSlateRangealone is insufficient because native text can still render outside the Slate value. - Prior learning: DOM selection stack traces can hide ownership bugs; here the linked discussion and current table normalizer point to missing mapped targets around tables plus a root-click guard.
docs/solutions/patterns/critical-patterns.mddoes not exist in this checkout.- Published package code is likely changing under
packages/; a changeset is required. - Forcing paragraphs around tables is too broad: it shifts path-targeted table operations. The fix guards unmapped root clicks by selecting the closest editable child point.
- Loaded
task,planning-with-files,tdd,learnings-researcher, anddev-browser. - Created branch
codex/4956-table-unmapped-dom-selectionfrom currentmain. - Red:
bun test packages/table/src/lib/withNormalizeTable.spec.tsx packages/table/src/react/onMouseDownTable.spec.tsxfailed on missingonMouseDownTable. - Full table suite exposed adjacent-table normalization as path-breaking; removed that approach.
- Green:
bun test packages/table/srcpassed. - Package gate passed:
pnpm install,pnpm turbo build --filter=./packages/table,pnpm turbo typecheck --filter=./packages/table,pnpm lint:fix. - Browser gate passed on
http://localhost:3000/docs/table: root click target wasdata-slate-node="value", selection moved to a Slate text node, typed text stayed in the table, and no console/page errors fired. Screenshot:/Users/zbeyens/.dev-browser/tmp/plate-4956-table-unmapped-click-fixed.png. - PR gate passed:
pnpm check. - Compounded the reusable learning in
docs/solutions/ui-bugs/2026-04-25-table-root-clicks-must-recover-selection.md.