Skip to content
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

Problems with references after copying default sequence flow elements #1935

Closed
ChaominRuan opened this issue Aug 2, 2023 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@ChaominRuan
Copy link
Contributor

Describe the Bug

After setting the sequence flow to be the default sequence flow and using the shortcut key to copy the element, you will find that the element business object default property becomes enumerable and there is a circular reference. Importing a diagram, or switching the sequence flow to the default sequence flow after a normal element's default property is not enumerable.

as shown below :

20230801201123

Steps to Reproduce

  1. Create a start event, gateway and end event element.
  2. Connect them, with the flow between the gateway and end event set to the default flow.
  3. Select the gateway and end event element and copy it.

code example in stackblitz and run

Expected Behavior

When copied, the default properties of a business object should be no enumerable. This avoids unexpected problems, e.g. TypeError: Converting circular structure to JSON when using JSON.stringify.

Environment

  • Browser: [e.g. IE 11, Chrome 110]
  • OS: [e.g. Windows 7]
  • Library version: [e.g. 2.0.0]
@philippfromme
Copy link
Contributor

The behavior you're observing is correct. We're not talking about a simple object here. Every model element is an instance of Base. When using JSON.stringify you have to make sure the references are handled. You can see an example here: https://github.com/nikku/bpmn-js-copy-paste-example

@ChaominRuan
Copy link
Contributor Author

The behavior you're observing is correct. We're not talking about a simple object here. Every model element is an instance of Base. When using JSON.stringify you have to make sure the references are handled. You can see an example here: https://github.com/nikku/bpmn-js-copy-paste-example

I found this problem exactly when I was using the example you mentioned!
https://github.com/nikku/bpmn-js-copy-paste-example/blob/master/test/copy-paste.js#L45 JSON.stringify(tree) is used here.

In the model it's using defineProperty: https://github.com/bpmn-io/moddle/blob/master/lib/properties.js#L51,
but in BpmnCopyPaste.js it's mounted directly on the object's property https://github.com/bpmn-io/bpmn-js/blob/develop/lib/features/copy-paste/BpmnCopyPaste.js#L111
So there's this problem.

@philippfromme
Copy link
Contributor

Closed by ca65cde.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants