Skip to content

When trying to restore a NodeSelection for selected, deleted inline node - the NodeSelection constructor will throw an error #202

@bdbch

Description

@bdbch

Please save me some time and use the following template. In 90% of all issues I can't reproduce the problem because I don't know what exactly you are doing, in which environment, or which y-* version is responsible. Just use the following template even if you think the problem is obvious.

Checklist

Describe the bug
This bug is an edge case where an inline atom node is selected by Client A will throw an error and reject the document change when Client B removes that node.

The reason why this happens is, because the NodeSelection class constructor assumes that nodeAfter will exist on the resolved position which it usually does in cases where the resolved position points between nodes in block level nodes. (See here).

However when you have an inline atom node, that is inside a paragraph, this logic can fail because in this case the resolved position won't point to the doc and in between block level nodes but will point inside the now empty paragraph node.

When this happens, nodeAfter is null on the resolved pos and the constructor will throw an error and the content will be rejected from Client A.

To Reproduce
Steps to reproduce the behavior:

  1. Create a schema with an inline atom node (not verified if it only happens for atom nodes though)
  2. Create a document with said node inside a paragraph
  3. Client A selects the custom node, Client B deletes the custom node
  4. Client A's runtime will now throw an error because nodeAfter is undefined and the content change is rejected on Client A's side.

Expected behavior
The content should not be rejected and the selection should fall back to a TextSelection.

Screenshots
N/A

Environment Information

  • Google Chrome & Firefox - all up to date
  • Sadly I don't have information about the exact yjs and y-prosemirror versions being used.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions