Nested blocks issue
See original GitHub issueThere is problem with transformations of doubly nested blocks (document - documentNode - nestedNode - doubleNestedNode). There is problem in following cases:
- caret at end of the doubleNestedNode, press delete
- caret at beggining of (not first) node, press backspace
- paste selection of more than one block
Uncaught Error: Could not find a node with key "47".
at Document.assertNode
at Object.normalizeNodeByKey
at Transform.(anonymous function) [as normalizeNodeByKey]
at Object.deleteAtRange
at Transform.(anonymous function) [as deleteAtRange]
at Object.deleteBackwardAtRange
at Transform.(anonymous function) [as deleteBackwardAtRange]
at Object.deleteCharBackwardAtRange
at Transform.(anonymous function) [as deleteCharBackwardAtRange]
at Object.deleteCharBackward
Double nested blocks have actually multiple issues and strange behaviors that regular nested blocks does not have. For example backspace with caret at first double nested block deletes without producing error, but deletes whole content of nestedBlock keeping only first doubleNestedBlock.
I am aware that this could be solved with custom plugin, but since Slate supports unlimited nesting of blocks, this should be probably solved in core.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:8 (8 by maintainers)
Top Results From Across the Web
The Problem with Nested Blocks and AdditionalViewData - Blog
This issue can happen with any data passed with PropertyFor as additionalViewData. It can be as minor as a persisting CssClass, or more...
Read more >Nested blocks are triggering error · Issue #109 - GitHub
When nesting blocks error is triggered. Block of code is taken from latte documentation (https://latte.nette.org/en/tags#toc-blocks) so it should be OK.
Read more >Nested block issues - Rhino for Windows - McNeel Forum
I am working on a project with big components that I split up into blocks. Say Block_A and Block_B. I then have a...
Read more >What problems are caused by nested Blocks? - Stack Overflow
First of all a block copies "virtually" all reachable local vars of a program. Of course this is optimized by the compiler.
Read more >Nested Blocks: Using InnerBlocks | Block Editor Handbook
A common pattern for using InnerBlocks is to create a custom block that will be included only in the InnerBlocks. An example of...
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
@Mangatt agreed, there appears to be a class of issues related to deeply nested block handling.
I opened #917 to address one aspect of it. Here’s what I found (again, just one aspect of a greater issue):
Transform.insertFragmentAtRange
checks the first and last leaf blocks, and if they are not the same, it removes the parent of the first leaf block pending a potential node split. The intention is to add the first leaf node parent back in after the split.lonelyParent
simply requires the parent to contain only one node. This doesn’t account for that one node having multiple children.moveNodeByKey
.I’ve minimally reproduced this in a Fiddle: https://jsfiddle.net/erquhart/L05uz8qp/2/
My PR addresses this particular case, but there seem to be many more. For example, if you paste into a selection, which requires a split, you get new errors associated with marks.
The ideal approach is to find the underlying shared assumptions that cause deeply nested fragments to be mishandled.
@ianstormtaylor we’ll likely need your help getting this going. Do you recall running into any issues like this?
This issue hasn’t had a response in a while, and it’s unclear if it’s still present in the latest versions of Slate. To keep the issues easier to manage, since there are so many being opened every day, I’m going to close this old one out.
But if you notice that the bug is still happening, please feel free to comment and it can be revisited. It might be an edge case that not many people run into, in which case the fastest way to get it fixed would probably be to write a pull request for it.
Thanks for understanding!