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
If you copy & paste a collapsed subprocess with some elements inside and try to undo this action, editor crashes.
Root cause
When a collapsed subprocess is pasted,
elements.create
command is triggered and triggers following actions:shape.create
for a new subprocess element.elements.move
for subprocess children (triggered post-shape.create
by `SubProcessPlaneBehavior)shape.create
for each child.When this action is being undone, subprocess children are first removed (revert
shape.create
) and then are attempted to be moved back to their original parent/position (revertelements.move
) which doesn't make sense as those elements are already removed.Proposed solution
I believe the correct implementation of subprocess plane behavior should move the elements onto the new plane after they are all created, so on
postExecuted
ofelements.create
instead ofshape.create
.This pull requests does it and therefore solve the paste & undo bug.
New problem
Unfortunately, the subprocess element in the
context
ofelements.create
handler doesn't have all its children. It's missing labels and text annotations. Those elements are still copied, but remain hidden on the root plane.Additional context
Initial discussion and debugging session: bpmn-io/diagram-js#957 (comment).
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}