-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(planes): ensure we switch to existing plane #598
Conversation
modeling.removeShape(shape2); | ||
|
||
// remove and re-add the plane, e.g. when removing a subprocess and undoing it | ||
canvas.setRootElementForPlane(null, plane, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What we're doing here is essentially operating on two different layers: Doing a modeling operation on the one hand, and doing low level operations (testing exactly what?) on the other hand.
What I'd personally like here is to create a simple test command that executes a real world use-case, i.e. do/undo/redo of adding plane + switching to it, adding an element and so forth. Then we have something that works end-to-end and can be tested in an integration test manner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example:
- Implement a behavior that creates a plane any time an element is being created
- Drill into that plane, add a task
- Undo both things (and see how active planes change); re-do both things (and again, verify what is happening).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general remark, I do not understand why this PR would be necessary.
Re-doing a certain operation shall re-use what we already got (i.e. rootElements, planes). So it shall be safe to refer to them by reference, not ID (or name). If a plane gets added again, after redo, it shall be the exact same plane.
Referencing by name may cause other issues, i.e. if the name changes.
I agree that this would be the desired behavior. Currently, Canvas does not offer an API to create a Plane from an element: Lines 367 to 376 in 3244df4
It will always create a new plane descriptor. So the fix for this Issue would be to expand the Canvas API so we can reuse Plane descriptors. e.g.: eecc65d Should I adjust this PR or create a new one as this is another concern? |
Fine with either. Exactly. |
superseded by #599 |
With the ability to remove planes, we have to adjust the Behavior that switches planes during command executions. We should use names instead of plane object when switching planes.
This fixes a scenario that is caused during bpmn-js modeling:
Because the behavior for adding/removing planes is part of bpmn-js, but switching to the correct plane is a diagram-js concern, I had to manually remove the plane+root element and could not use the command stack in the tests.