Skip to content

[examples] Undo does not restore content after replacing a Cmd+A selection #11

Description

@wudidewo12

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/mentions

Reference URL:

https://www.slatejs.org/examples/mentions

Steps

To reproduce the behavior:

  1. Go to http://localhost:3100/examples/mentions.
  2. Click inside the Mentions editor.
  3. Press Cmd+A.
  4. Type Z.
  5. Press Cmd+Z.
  6. Repeat the same steps on 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 Z after pressing Cmd+Z. The original Mentions document content is not restored.

Environment

  • Local URL: http://localhost:3100/examples/mentions
  • Reference URL: https://www.slatejs.org/examples/mentions
  • Local branch/commit: v2, ce2bd6c6
  • Browser: Chrome
  • OS: macOS
  • Local app setup: Slate examples site served locally with bun serve

Additional scope:

The same behavior also reproduces in examples/inlines and examples/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:

  1. Open http://localhost:3100/examples/inlines.
  2. Click inside the editor.
  3. Press Cmd+A.
  4. Type Z.
  5. Press Cmd+Z.
  6. Compare with https://www.slatejs.org/examples/inlines.

On localhost, the editor still shows only Z after Cmd+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.

Activity

  1. 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
  2. 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
  3. 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
  4. zbeyens commented on May 10, 2026

    @zbeyens
    Member

    🟡 80-94% confidence

    Phase 🧪 Tests 🌐 Browser
    Reproduced ✅ Issue video shows full Cmd+A replacement 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 inlines and tables. 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.ts
    • cd /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
  5. wudidewo12 commented on May 22, 2026

    @wudidewo12
    Author

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions