question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Delete all will fail when there are three blocks or more

See original GitHub issue

EDIT: 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:

  1. Goto the emoji-example
  2. Add an emoji at the end of the last block.
  3. Select everything (command/ctrl-A)
  4. 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:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:42 (27 by maintainers)

github_iconTop GitHub Comments

2reactions
skogsmaskincommented, Oct 25, 2018

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! ❤️

2reactions
ericedemcommented, Oct 25, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found