Repository navigation
[examples] Undo does not restore content after replacing a Cmd+A selection #11
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Activity
- changed the title
[-][examples/mentions] Undo does not restore content after replacing a Cmd+A selection[/-][+][examples/inlines, mentions] Undo does not restore content after replacing a Cmd+A selection[/+]on May 7, 2026 - changed the title
[-][examples/inlines, mentions] Undo does not restore content after replacing a Cmd+A selection[/-][+]Since the editor is based on a recursive tree model, similar to an HTML document, you can create complex nested structures, like tables: HumanDogCat# of Feet244# of Lives119This table is just a basic example of rendering a table, and it doesn't have fancy functionality. But you could augment it to add support for navigating with arrow keys, displaying table headers, adding column and rows, or even formulas if you wanted to get really crazy![/+]on May 7, 2026 - changed the title
[-]Since the editor is based on a recursive tree model, similar to an HTML document, you can create complex nested structures, like tables: HumanDogCat# of Feet244# of Lives119This table is just a basic example of rendering a table, and it doesn't have fancy functionality. But you could augment it to add support for navigating with arrow keys, displaying table headers, adding column and rows, or even formulas if you wanted to get really crazy![/-][+][examples] Undo does not restore content after replacing a Cmd+A selection[/+]on May 7, 2026 🟡 80-94% confidence
Phase 🧪 Tests 🌐 Browser Reproduced ✅ Issue video shows full Cmd+Areplacement undo losing original content✅ Reported on Mentions, with extra scope for Inlines and Tables Verified 🟢 Mentions select-all replacement undo row and package history contract are green on current v2 07d79634⚠️ Extra listed examples still need route-specific proof🌐 Browser Check
- Open
http://localhost:3100/examples/mentions. - Click inside the editor.
- Press
Cmd+A. - Type
Z. - Press
Cmd+Z. - Confirm the original Mentions document is restored.
✅ Outcome
- Current v2 restores the Mentions document after full-selection replacement undo.
- The package history contract records full-document selected text replacement as one structural undo batch.
⚠️ Caveat- The issue also names
inlinesandtables. The core history contract is green, but this pass did not run browser rows for those extra routes, so I am leaving this open until those are confirmed.
🏗️ Design
- Chosen owner: structural replacement history batching.
- Why not quick patch: the current Mentions browser row and package history contract are already green.
- Why not broader change: cross-example closure needs matching browser proof for each claimed route.
🧪 Verified
cd /Users/zbeyens/git/slate-v2 && bun test ./packages/slate-history/test/history-contract.tscd /Users/zbeyens/git/slate-v2 && PLAYWRIGHT_RETRIES=0 PLAYWRIGHT_BASE_URL=http://localhost:3100 bun playwright playwright/integration/examples/plaintext.test.ts playwright/integration/examples/mentions.test.ts playwright/integration/examples/paste-html.test.ts playwright/integration/examples/iframe.test.ts --project=chromium --grep "keyboard undo restores caret after middle-line typing|keyboard undo restores partial selected text replacement|keyboard undo restores select-all replacement content|copies and pastes a selected mention without crashing|cuts a selected mention without crashing|pastes copied rendered Slate content as an internal fragment before HTML import|applies parent toolbar formatting to selected iframe text"cd /Users/zbeyens/git/slate-v2 && bun check
- Open
Retested on current v2 commit e62c204.\n\nChecked the filed cross-example scope:\n- Mentions: click editor, Cmd+A, type Z, Cmd+Z restores the original document.\n- Inlines: click editor, Cmd+A, type Z, Cmd+Z restores the original document.\n- Tables: click editor, Cmd+A, type Z, Cmd+Z restores the original document.\n\nNo runtime errors were observed in these retest paths. Closing because the reported Cmd+A replacement undo behavior no longer reproduces in the covered examples.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Description
In multiple Slate examples, replacing the whole editor selection with a single character and then undoing does not restore the original content locally. The live reference restores the original document.
Recording
Screenshots attached below:
Local actual behavior:
Live reference expected behavior:
Video attached below:
CleanShot.2026-05-07.at.18.16.55.mp4
Sandbox
No standalone sandbox. Reproduced in the Slate examples site.
Local reproduction URL:
http://localhost:3100/examples/mentionsReference URL:
https://www.slatejs.org/examples/mentionsSteps
To reproduce the behavior:
http://localhost:3100/examples/mentions.Cmd+A.Z.Cmd+Z.https://www.slatejs.org/examples/mentions.Expectation
After pressing
Cmd+Z, the editor should restore the original Mentions document content, matching the live reference.Actual behavior
On localhost, the editor remains as
Zafter pressingCmd+Z. The original Mentions document content is not restored.Environment
http://localhost:3100/examples/mentionshttps://www.slatejs.org/examples/mentionsv2,ce2bd6c6bun serveAdditional scope:
The same behavior also reproduces in
examples/inlinesandexamples/tables.This is now tracked as a cross-example issue. I will retest it as an existing issue after future pulls instead of opening per-example duplicates.
Steps checked:
http://localhost:3100/examples/inlines.Cmd+A.Z.Cmd+Z.https://www.slatejs.org/examples/inlines.On localhost, the editor still shows only
ZafterCmd+Z. The live reference restores the original Inlines document.Impact
This breaks undo behavior after replacing a full editor selection across multiple Slate examples
. A normal select-all, replace, undo workflow can leave the document content lost locally instead of restoring the previous content.