Skip to content

[examples] Undo restores only part of a replaced partial text selection #12

@wudidewo12

Description

@wudidewo12

Description

In the Plain Text example, replacing a dragged partial text selection and then pressing Cmd+Z does not restore the full original selected text locally. The live reference restores the selected text correctly.

This is separate from the full Cmd+A replacement undo issue because this reproduction uses a normal partial text selection inside one paragraph.

Recording

Screenshots attached below:

Local actual behavior:

Image

Live reference expected behavior:

Image

Video attached below:
[optional; screenshots should be enough unless the drag-select/type/undo sequence is unclear]

Sandbox

No standalone sandbox. Reproduced in the Slate examples site.

Local reproduction URL:

http://localhost:3100/examples/plaintext

Reference URL:

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

Additional confirmed scope:

This issue is not limited to the original Plain Text reproduction. The same partial-selection replacement undo problem has now been reproduced across multiple Slate examples, including:

  • examples/plaintext
  • examples/inlines
  • examples/styling
  • examples/code-highlighting

In each case, selecting part of the editor text, typing replacement text, and pressing Cmd+Z does not fully restore the original selected text locally. The live reference restores the selected text correctly.

In examples/inlines, selecting links, typing URLs, then pressing Cmd+Z leaves localhost as There are two ways to add U...; selecting existing link text hyperlink, typing wiki, then pressing Cmd+Z leaves localhost link text as w. The live reference restores the original selected text in both checks.

In examples/styling, selecting the word using, typing changed, then pressing Cmd+Z leaves localhost with only c restored in place of the selected word. The live reference restores using.

Styling steps checked:

  1. Open http://localhost:3100/examples/styling.
  2. Select the word using in either styled editor.
  3. Type changed.
  4. Press Cmd+Z.
  5. Compare with https://www.slatejs.org/examples/styling.

Steps

To reproduce the behavior:

  1. Go to http://localhost:3100/examples/plaintext.
  2. Drag-select the word plain , including the trailing space, from the sentence This is editable plain text, just like a <textarea>!.
  3. Type simple.
  4. Press Cmd+Z.
  5. Repeat the same steps on https://www.slatejs.org/examples/plaintext.

Expectation

After pressing Cmd+Z, the editor should restore the original text:

This is editable plain text, just like a <textarea>!

Actual behavior

On localhost, after pressing Cmd+Z, the original selected text is not restored. The editor becomes:

This is editable stext, just like a <textarea>!

The live reference restores the original plain selection.

Environment

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

Impact

This breaks a normal text editing undo workflow. Replacing a partial text selection and undoing can leave corrupted text locally instead of restoring the original selected text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions