Skip to content

[examples] Cmd+Z after text input moves the caret to the beginning of the current line #9

@wudidewo12

Description

@wudidewo12

Description

After typing normal text in the middle of an existing line and pressing Cmd+Z, the caret can jump to the beginning of the current visual line.

This is not specific to examples/editable-voids. The tester observed the same caret restoration problem across multiple Slate examples.

This is separate from the Chinese IME composition issue. This issue uses normal text input followed by Cmd+Z.

Recording

Screenshots attached below:

Local actual behavior:

Live reference expected behavior:

Video attached below:

CleanShot.2026-05-07.at.15.08.39.mp4

Sandbox

No standalone sandbox. Reproduced in the Slate examples site.

Local reproduction URL examples:

http://localhost:3100/examples/plain-text

http://localhost:3100/examples/richtext

http://localhost:3100/examples/images

http://localhost:3100/examples/editable-voids

Live reference URL examples:

https://www.slatejs.org/examples/plain-text

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

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

https://www.slatejs.org/examples/editable-voids

Steps

To reproduce the behavior:

  1. Open any Slate example with editable text, such as examples/plain-text, examples/richtext, examples/images, or examples/editable-voids.
  2. Click in the middle of an existing visual line of text.
  3. Type a short marker string, such as abc.
  4. Press Cmd+Z.
  5. Observe where the caret is restored after the typed text is undone.

Expectation

After undoing the typed text, the caret should remain near the original edit position.

Live reference expected behavior:

  • The typed text is undone.
  • The caret does not jump to the beginning of the current visual line.

Actual behavior

Local actual behavior:

  • The typed text is undone.
  • The caret jumps to the beginning of the current visual line.

Environment

  • Slate Version: v2 branch, commit ce2bd6c6
  • Operating System: macOS
  • Browser: Chrome
  • Local examples site: http://localhost:3100
  • Live reference site: https://www.slatejs.org
  • TypeScript Version: No response

Context

This is a cross-example caret/selection restoration issue after normal typing and undo. It should be tracked separately from:

  • Chinese IME composition caret offset issues.
  • Editable Voids runtime crashes during focus/undo interactions.

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