Collapsed subprocess paste & undo bugfix #2275
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When a collapsed subprocess with children is pasted, the children are first created on the canvas root and then moved into the new subprocess.
When this action is undone, editor crashes because it attempts to move an element to the parent which is already removed from the canvas.
This seems to be a problem with order of operations - our subprocess implementation should first create all elements, then move them and undo those in the opposite order, but it seems to revert move action for some elements which parent was already removed (
shape.create.revert
).Proposed solution
This pull request adds a test to cover this case (569ce9f) and proposes to move children into the new subprocess after all elements are created.
Unfortunately, this causes a problem with text annotations and labels which are not getting copied now.
Additional context
For more detailed debugging discussion see bpmn-io/diagram-js#957 (comment) and below.
Closes #2269
Checklist
To ensure you provided everything we need to look at your PR:
@bpmn-io/sr
toolCloses {LINK_TO_ISSUE}
orRelated to {LINK_TO_ISSUE}