-
Notifications
You must be signed in to change notification settings - Fork 58
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
[2443] Use dynamic handles #2474
Conversation
949572a
to
320828b
Compare
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.
I have not yet reviewed everything in depth, but I prefer publishing my current remarks now so that we can iterate instead of waiting any longer.
It's too late now, but the PR mixes several changes that should probably have been done separately and iteratively. As it is, it's difficult to follow what code changes correspond to which UI/behavior change between:
- distinguish between the "create connection" handles displayed on a node to start the edge creation process from the "edge source/target handle" displayed on an edge to trigger a reconnection;
- only display the "create connection" handles (resp. "edge source/target handle") on a node (resp. edge) when it is selected);
- hightlight the compatible nodes (and fade the incompatible ones) during the edge creation process (actually, this does not seem to work as expected);
- distribute the endpoints of multiple edges which share the same side of a node so that they are visually distinguished.
The names chosen (especially "Custom Handle") do not help.
Cypress tests should also be added.
...diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/node/RectangularNode.tsx
Outdated
Show resolved
Hide resolved
...diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/node/RectangularNode.tsx
Outdated
Show resolved
Hide resolved
...diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/node/RectangularNode.tsx
Outdated
Show resolved
Hide resolved
packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/node/ListNode.tsx
Outdated
Show resolved
Hide resolved
.../frontend/sirius-components-diagrams-reactflow/src/renderer/node/ConnectionSourceHandles.tsx
Outdated
Show resolved
Hide resolved
packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/converter/convertDiagram.ts
Outdated
Show resolved
Hide resolved
.../frontend/sirius-components-diagrams-reactflow/src/renderer/node/ConnectionTargetHandles.tsx
Outdated
Show resolved
Hide resolved
.../frontend/sirius-components-diagrams-reactflow/src/renderer/node/ConnectionTargetHandles.tsx
Outdated
Show resolved
Hide resolved
...agrams/frontend/sirius-components-diagrams-reactflow/src/renderer/node/ConnectionHandles.tsx
Outdated
Show resolved
Hide resolved
2b49422
to
146279b
Compare
6008336
to
b56e151
Compare
b56e151
to
5619fe8
Compare
5619fe8
to
70f1bb9
Compare
packages/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/node/ImageNode.tsx
Outdated
Show resolved
Hide resolved
...ms/frontend/sirius-components-diagrams-reactflow/src/renderer/connector/ConnectorContext.tsx
Outdated
Show resolved
Hide resolved
} else { | ||
updateNodeInternals(id); | ||
} | ||
}, [JSON.stringify(data.connectionHandles)]); |
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.
Not sure about this, this looks like a potential performance issue.
Same remark for the other kinds of nodes.
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.
- This code should not be there, we don't want to repeat that code in every single node, this belongs in a dedicated handle hook. Custom shapes will have to reuse it for example.
- Why do you need this ref? Why not a state?
I agree with @pcdavid, on top of being a potential performance issue, you do not have any idea of what would this behavior be in the future. That being said, it works for a large number of use cases it can be a pretty code solutions BUT, and I say this "but" with every single letter in upper case, I think that the unique place where this code would be needs a link to the original explanation which details why we need to be VERY VERY careful with this kind of solutions: facebook/react#14476 (comment)
Honestly, given the use case, I would rather have something like this:
const connectionHandlesIdentity = data.connectionHandles
.map(handle => `${handle.nodeId}#${handle.edgeId}`)
.join(', ');
useEffect(() => { ... }, [connectionHandlesIdentity])
The main difference being that if we change the structure of ConnectionHandle, we can select whether or not this code should be impacted.
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.
Thanks for the explanation, I'll use a string as dependency of the useffect and put it in a custom hook then.
I used a ref because a state change would trigger a re render (unlike a ref change) and call updateNodeInternals which if called too much can impact the performance a lot. From my testing in this particular use case I get more render by using a state than a ref.
70f1bb9
to
452b750
Compare
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.
There are some known issues/possible improvements, but the basics are in place and work. @sbegaudeau unless you see something that jusitfies a veto from you, I say we merge this and continue improving in further PRs.
452b750
to
a29d86b
Compare
Bug: #2443 Signed-off-by: Michaël Charfadi <[email protected]>
a29d86b
to
e61b81b
Compare
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.
Just to prevent this being merged before we decide how to proceed.
83cdc54
to
8ca080e
Compare
Bug: #2443
Pull request template
General purpose
What is the main goal of this pull request?
Project management
priority:
andpr:
labels been added to the pull request? (In case of doubt, start with the labelspriority: low
andpr: to review later
)area:
,difficulty:
,type:
)CHANGELOG.adoc
been updated to reference the relevant issues?CHANGELOG.adoc
? (Including changes in the GraphQL API)CHANGELOG.adoc
? For example indoc/screenshots/2022.5.0-my-new-feature.png
Architectural decision records (ADR)
[doc]
?CHANGELOG.adoc
?Dependencies
CHANGELOG.adoc
?CHANGELOG.adoc
?Frontend
This section is not relevant if your contribution does not come with changes to the frontend.
General purpose
Typing
We need to improve the typing of our code, as such, we require every contribution to come with proper TypeScript typing for both changes contributing new files and those modifying existing files.
Please ensure that the following statements are true for each file created or modified (this may require you to improve code outside of your contribution).
useMutation<DATA_TYPE, VARIABLE_TYPE>(…)
useQuery<DATA_TYPE, VARIABLE_TYPE>(…)
useSubscription<DATA_TYPE, VARIABLE_TYPE>(…)
useMachine<CONTEXT_TYPE, EVENTS_TYPE>(…)
useState<STATE_TYPE>(…)
?.
(if the GraphQL API specifies that a field cannot benull
, do not treat it has potentiallynull
for example)let diagram: Diagram | null = null;
)Backend
This section is not relevant if your contribution does not come with changes to the backend.
General purpose
Architecture
Review
How to test this PR?
Please describe here the various use cases to test this pull request