-
Notifications
You must be signed in to change notification settings - Fork 29
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(Canvas): Fix CustomNode rerendering without controller #1922
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1922 +/- ##
============================================
+ Coverage 78.51% 78.58% +0.06%
Complexity 367 367
============================================
Files 469 468 -1
Lines 14816 14824 +8
Branches 2832 2835 +3
============================================
+ Hits 11633 11649 +16
+ Misses 3095 2904 -191
- Partials 88 271 +183 ☔ View full report in Codecov by Sentry. |
When performing D&D, the following occurs: 1. The graph model gets reset 2. A structural change in the VisualEntity 3. The nodes rerenders 4. There are failuers in the console due to nodes being rerendered without having a controller, because it was removed during the node removal process The first solution for this is to set an empty model to the visualization controller so it removes all nodes from the canvas, then due to the recreation of the visual entities, the canvas will be repopulated. While this works in the browser, when running Kaoto through the Multiplying Architecture, it doesn't work, very likely because of the react versions mismatch (web: 18, MA: 17). The second iteration of the solution is to schedule the entities recreation outside of react, by using `requestAnimationFrame`, this way, the canvas will be cleared before recreating the visual entities. Almost everything boils down to the fact that because the vizNodes are being recreated during the visualization, and since they are stored in the data property of the canvas nodes, the CustomNodes and CustomGroups are being rerendered, due to the use of `observer` from `mobx`. A more future-proof solution would be to remove the `vizNode` objects from the data properties, so the rerendering process occurs without taking those into consideration. fix: KaotoIO#1888
cdb4548
to
2d39d36
Compare
Quality Gate passedIssues Measures |
Context
When performing D&D, the following occurs:
The first solution for this is to set an empty model to the visualization controller so it removes all nodes from the canvas, then due to the recreation of the visual entities, the canvas will be repopulated.
While this works in the browser, when running Kaoto through the Multiplying Architecture, it doesn't work, very likely because of the react versions mismatch (web: 18, MA: 17).
The second iteration of the solution is to schedule the entities recreation outside of react, by using requestAnimationFrame`, this way, the canvas will be cleared before recreating the visual entities.
Almost everything boils down to the fact that because the vizNodes are being recreated during the visualization, and since they are stored in the data property of the canvas nodes, the CustomNodes and CustomGroups are being rerendered, due to the use of
observer
frommobx
.A more future-proof solution would be to remove the
vizNode
objects from the data properties, so the rerendering process occurs without taking those into consideration.fix: #1888