-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Set viewport when nodes dimensions are ready #12730
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
Set viewport when nodes dimensions are ready #12730
Conversation
… they get available
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:41562 This environment will automatically shut down when the PR is closed or after 5 hours. |
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.
PR Summary
Implements a more robust viewport calculation system for workflow diagrams by ensuring node dimensions are properly computed before setting the viewport position.
- Added new
workflowDiagramWaitingNodesDimensionsComponentState
to track dimension computation status using Recoil state management - Modified
WorkflowDiagramCanvasBase
to prevent premature viewport calculations when node dimensions are reset or invalid - Leverages
ComputeNodeDimensions
utility to ensure accurate dimension measurements before bounds calculation - Integrates with optimistic rendering for workflow runs to maintain viewport stability
- Improved viewport calculation to properly handle right drawer states and prevent incorrect positioning
2 files reviewed, no comments
Edit PR Review Bot Settings | Greptile
Sometimes, we try to set the viewport, but the nodes' dimensions have been reset. Trying to set the viewport when the nodes' dimensions are incorrect leads to an incorrect viewport. This PR ensures we only try to set the viewport if the nodes' dimensions are valid. Otherwise, we wait for them to be computed to set the viewport automatically. The `handleNodesChanges` function is called every time the nodes change, including when the dimensions have been computed. Internally, Reactflow has a similar behavior to implement the `fitView` feature: https://github.com/xyflow/xyflow/blob/f9971a8fad54e9c2f33b71b4056b6d1ec6c33bd1/packages/react/src/store/index.ts#L111. ## Example This is more notable since I added optimistic rendering to workflow runs. https://github.com/user-attachments/assets/07232050-b808-4345-b82b-95acad72ab15
Sometimes, we try to set the viewport, but the nodes' dimensions have been reset. Trying to set the viewport when the nodes' dimensions are incorrect leads to an incorrect viewport.
This PR ensures we only try to set the viewport if the nodes' dimensions are valid. Otherwise, we wait for them to be computed to set the viewport automatically.
The
handleNodesChanges
function is called every time the nodes change, including when the dimensions have been computed.Internally, Reactflow has a similar behavior to implement the
fitView
feature: https://github.com/xyflow/xyflow/blob/f9971a8fad54e9c2f33b71b4056b6d1ec6c33bd1/packages/react/src/store/index.ts#L111.Example
This is more notable since I added optimistic rendering to workflow runs.
CleanShot.2025-06-19.at.16.50.41.mp4