handleNewLine does not produce the right undo stack when breaking out of a block
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 286
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
This is best demonstrated with a GIF:
https://jsfiddle.net/thibaudcolas/Lo2zL37h/

Here I'm pressing return once and then undoing it with ctrl + Z, but it takes two undo operations to get back to the pre-newline state.
The problem is that after insertNewUnstyledBlock produces the split-block change, removeSelectedBlocksStyle makes a change-block-type. This should be a single operation.
It might be enough to use Modifier.setBlockType(content, selection, 'unstyled') directly in insertNewUnstyledBlock. I'm happy to try and make a PR doing this.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior using the linked jsfiddle, then inspect handleNewLine, insertNewUnstyledBlock, and removeSelectedBlocksStyle. Trace the split-block and change-block-type changes around a return in a block. Done means one undo operation returns the editor to its pre-newline state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100