-
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
feat(Canvas): Replace autofit by keeping zoom level and ensuring selected item is visible #1469
Conversation
26f3f20
to
4ab3e40
Compare
useEffect(() => { | ||
const timeoutId = setTimeout( | ||
action(() => { | ||
controller.getGraph().fit(80); | ||
}), | ||
500, | ||
); | ||
|
||
return () => { | ||
clearTimeout(timeoutId); | ||
}; | ||
}, [controller, selectedIds]); | ||
|
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.
Removing the zoom-out functionality to fit the entire flow.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1469 +/- ##
=======================================
Coverage ? 68.98%
Complexity ? 26
=======================================
Files ? 272
Lines ? 7752
Branches ? 1496
=======================================
Hits ? 5348
Misses ? 2401
Partials ? 3 ☔ View full report in Codecov by Sentry. |
4ab3e40
to
78d1c32
Compare
78d1c32
to
5bedff2
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 a comment on the issue you were seeing. Just something I noticed with a quick look.
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.
- several tests are failing
- in VS Code, the properties panel is not opening anymore
EDIT: infact, the properties panel is not opening either with standalone mode
note: for a more positive vision (and I think more accurate), I would replace |
const lastUpdate = useMemo(() => Date.now(), [props.entities]); | ||
|
||
return ( | ||
<div className={`canvas-surface ${props.className ?? ''}`}> | ||
<ErrorBoundary key={lastUpdate} fallback={props.fallback ?? <CanvasFallback />}> | ||
<VisualizationProvider controller={controller}> |
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.
Moving the VisualizationProvider
here, to avoid recreating it whenever the entities
array change.
requestAnimationFrame(() => { | ||
controller.fromModel(model, 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.
Added the requestAnimationFrame
cc @jeff-phillips-18
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.
Currently, when selecting a node in the canvas, there is an existing fuctionality to center the view. This helps to keep the flow visible at all times, especially in cases when the side panel might overlap the flow. With complex flows, this behavior turns to be problematic, as the user might be zooming over a section of the flow, then selecting a node, effectively moving the viewport somewhere else. The fix is to remove the auto-center functionality so the zoom is ketp between node editing. fix: https://issues.redhat.com/browse/KTO-461
Currently, the visible-flow provider is initialized to an empty object `{}` and then updated through an `useEffect()`, causing that for the first render, it gets rendered twice. The fix is to use the `initializer` paramter from the `useReducer` hook.
Currently, when using chromium-based browsers, navigating to from a page to the Design page, makes the nodes render distorted. There are a few elements contributing to this behavior, first of all, the `visible-flow` provider was initialized to `{}`, causing to the `Canvas` component to be rendered twice, and after that, it seems like the `useEffect` callback that called `controller.fromModal` was batched after the `VisualizationSurface` was initialized, missing the update. The fix is to replace the `useEffect` callback with `useLayoutEffect` to ensure the nodes and edges are available before the `VisualizationSurface` component. fix: KaotoIO#1352
In order to preserve the nodes visible when opening the configuration panel, this commit schedules a `panIntoView` command to the selected node, preserving the zoom level while aiming for the less movement possible to make the node visible. relates: https://issues.redhat.com/browse/KTO-461
a17e379
to
7a6d574
Compare
When rendering the graph, we can see some flickering in a few situations: 1. The app is loaded for the first time or refreshed 2. Switching between no routes in the canvas and a adding a route 3. Navigating to a pages and go backto the design page 4. Disabling and enabling steps in the canvas 5. Switching the layout between horizontal and vertical The fix for those situations is: 1. Adding an `initialized` state to
7a6d574
to
ed422f6
Compare
Quality Gate failedFailed conditions |
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.
On functional side, I tested in VS Code and I have not found any problems.
Note that I do not understand the code changes and how it impacts the behavior change.
Thanks @apupier for the reviews 👍 |
Context
Currently, when selecting a node in the canvas, there is an existing functionality to center the view.
This helps to keep the flow visible at all times, especially in cases when the side panel might overlap the flow.
With complex flows, this behavior turns out to be problematic, as the user might be zooming over a section of the flow, and then selecting a node, effectively moving the viewport somewhere else.
In addition to that, when using chromium-based browsers, navigating from a page to the Design page, makes the nodes render distorted.
There are a few elements contributing to this behavior, first of all, the
visible-flow
provider was initialized to{}
, causing theCanvas
component to be rendered twice, and after that, it seems like theuseEffect
callback that calledcontroller.fromModal
was batched after theVisualizationSurface
was initialized, missing the update.Changes
The fix for the former is to remove the auto-center functionality so the zoom is kept between node editing, and for the latter, the fix is to replace the
useEffect
callback withuseLayoutEffect
to ensure the nodes and edges are available before theVisualizationSurface
component.Notes
Both fixes are complementary to each other, so they need to be merged together.
fix: #1352
fix: https://issues.redhat.com/browse/KTO-461