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.

Deleting selection across nested blocks results in an error (`Node.assertNode` could not find node with path or key)

See original GitHub issue

Do you want to request a feature or report a bug?

Bug. 🐛

What’s the current behavior?

When you select a list branch with more then three levels of nesting and try to delete it, it will result in an error. For example:

Node.assertNode could not find node with path or key: List [ 0, 1, 0, 0, 0, 0 ]

This behavior, however, won’t happen when you select multiple branches (see the recording).

CodeSandbox reproduction

https://codesandbox.io/s/6ykzw473wz

GIF

GIF

Environment
  • macOS High Sierra
  • Chrome 70
  • slate@0.42.6
  • slate-react@0.19.8

What’s the expected behavior?

Expected behavior is to delete the selected content.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
skogsmaskincommented, Oct 26, 2018

I’m pretty sure it’s happening here packages/slate/src/utils/path-utils.js#L323

The operation:

{
  "object": "operation",
  "type": "merge_node",
  "path": [
    0,
    1,
    0,
    1
  ],
  "position": 0,
  "properties": {
    "data": {}
  },
  "target": null
}

The result is List [ 0, 1, 0, 0, 0, 0 ]

pIndex is 3

The correct result should be List [ 0, 1, 0, 0]

Commenting out the else if makes my test pass (but of course breaks others tests), so it seems like there is missing an additional conditional there, but I have no idea what. Tried various.

  if (type === 'merge_node') {
    if (pEqual || pYounger) {
      path = decrement(path, 1, pIndex)
    } else if (pAbove) {
      // path = decrement(path, 1, pIndex)
      // path = increment(path, position, pIndex + 1)
    }
  }

@ianstormtaylor any ideas?

The replicated test document:

  <value>
    <document>
      <list>
        <item>
          <paragraph>
            If you start selecting here the issue won't occur.
          </paragraph>
        </item>
        <item>
          <paragraph>
            <anchor />START selecting here.
          </paragraph>
          <list>
            <item>
              <paragraph>Selected</paragraph>
            </item>
            <item>
              <paragraph>Selected</paragraph>
            </item>
            <item>
              <paragraph>Selected</paragraph>
              <list>
                <item>
                  <paragraph>Selected</paragraph>
                </item>
                <item>
                  <paragraph>
                    END selection here<focus />
                  </paragraph>
                </item>
              </list>
            </item>
          </list>
        </item>
      </list>
    </document>
  </value>
0reactions
ianstormtaylorcommented, Nov 28, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

jasonphillips-slate - UNPKG
'text') {\n logger.warn(\n 'The range focus was set to a Node that is not a Text ... throw new Error(`Could not find a...
Read more >
third_party/blink/renderer/core/inspector ... - Google Git
Response InspectorDOMAgent::AssertNode(int node_id, Node*& node) {. node = NodeForId(node_id);. if (!node). return Response::ServerError("Could not find ...
Read more >
https://opensource.apple.com/source/WebCore/WebCor...
pushNodePathToFrontend (node); if (!nodeId) return; m_domAgent. ... if (!parentNode) { errorString = "Cannot remove detached node"_s; return; } ...
Read more >
Changelog - Slate
This is a list of changes to Slate with each new release. Until 1.0 is released, breaking changes will be added as minor...
Read more >
https://www.postgresql.org/message-id/attachment/1...
The planner can include this node type in the plan to have the executor ... is no good way to know if a...
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