Bug. 🐛
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.assertNodecould 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).
https://codesandbox.io/s/6ykzw473wz

[email protected][email protected]Expected behavior is to delete the selected content.
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>
same error in Microsoft Edge 12 when I dragging text.
@skogsmaskin what is the initial path (passed into transform), the operation (passed into transform) and the resulting path (the return value of transform) in that case?
a failing test with this would be nice :+1:
Most helpful comment
I'm pretty sure it's happening here packages/slate/src/utils/path-utils.js#L323
The operation:
The result is
List [ 0, 1, 0, 0, 0, 0 ]pIndexis 3The correct result should be
List [ 0, 1, 0, 0]Commenting out the
else ifmakes 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.@ianstormtaylor any ideas?
The replicated test document: