Delete all will fail when there are three blocks or more
See original GitHub issueEDIT: previously this was only an issue when the last block ended in a inline void node. Now it is always an issue.
Do you want to request a feature or report a bug?
Bug
What’s the current behavior?
If you have three blocks or more, where the last block ends with an inline void node, and you select everything and hit backspace (delete), it will fail with error:
Uncaught Error: `Node.assertNode` could not find node with path or key: List [ 1 ]
Reproduction:
- Goto the emoji-example
- Add an emoji at the end of the last block.
- Select everything (command/ctrl-A)
- Hit backspace
What’s the expected behavior?
That everything will be deleted without error.
I have noticed that when deleting all (and you have three or more blocks) the change will include an operation with type move_node
where the path property is a block path (i.ie [2]
with the same value as the newPath prop [2]
. I think Slate will regenerate keys for this operation and it may lead to issues.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:42 (27 by maintainers)
Top Results From Across the Web
Unable to delete or purge a layer in AutoCAD
A layer that the block or definition is on will stay "used" until all blocks and their definitions are deleted and purged.
Read more >Documentation: 15: DELETE - PostgreSQL
DELETE deletes rows that satisfy the WHERE clause from the specified table. If the WHERE clause is absent, the effect is to delete...
Read more >Create and run a delete query - Microsoft Support
The DELETE statement is used to delete records in a table. See how to create and use a delete query in Access desktop...
Read more >Delete, disable & manage unused apps on Android
Delete, disable & manage unused apps on Android. You can uninstall apps you've installed on your phone. If you remove an app you...
Read more >Solved: the Device \Device\Harddisk0\DR0 has a Bad Block
Some users reported that they notice the error message “the Device ... This annoying problem is found to occur on multiple Windows versions....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Pushed an update to the PR. Now for a go at nuking that move_node(X,X) operation. Thanks a lot @ericedem, @Slapbox and @ianstormtaylor! ❤️
Ok I think I may have found the culprit, or at least something close. This bit of code: https://github.com/ianstormtaylor/slate/blob/master/packages/slate/src/commands/at-range.js#L228-L234
Which is why this is specifically failing with 3 or more blocks, because it is looking at the original start and end blocks which will never be next to each other. What happens in the case of 3 blocks is that move seems to be inadvertently adding or transforming one of the existing dirty paths to [ 2 ] (even though there isn’t a node at [ 2 ] at this point), which will eventually get changed to [ 1 ] by the merge (which both of these seem a little odd). Then when normalization happens [ 1 ] is invalid.