-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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: Add factor to prevent overlap #5426
Conversation
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 don't think a random factor is a good idea. If it is zero it will overlap unless you make it (1+random) * 100.
Does this fix all the cases where there could be overlap (e.g. when adding a component by clicking on the sidebar button)?
This commit adds the buildPositionDictionary function to reactflowUtils.ts. This function is used to build a dictionary of positions for nodes in the flow. It is necessary for managing the positions of nodes and preventing overlap.
This commit adds the setPositionDictionary function to the PageComponent in order to set the position dictionary for the flow. This function is used to update the position dictionary when the canvas is moved or resized. Co-authored-by: [Author Name]
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.
Seems good to me. Though, should it just increment the position by 1 (or some fixed distance) for x and y so it stays consistently diagonal? (i.e. why does it need the random factor?)
nice catch @jordanrfrazier, and it will require less dependencies |
the review is outadted to the current version
* fix: add random factor to prevent overlap * update package.lock * feat: Add positionDictionary and related functions to FlowStoreType * feat: Add buildPositionDictionary function to reactflowUtils.ts * feat: Add buildPositionDictionary function to reactflowUtils.ts This commit adds the buildPositionDictionary function to reactflowUtils.ts. This function is used to build a dictionary of positions for nodes in the flow. It is necessary for managing the positions of nodes and preventing overlap. * fix: Remove random factor from paste function in PageComponent * [autofix.ci] apply automated fixes * feat: Add setPositionDictionary function to PageComponent This commit adds the setPositionDictionary function to the PageComponent in order to set the position dictionary for the flow. This function is used to update the position dictionary when the canvas is moved or resized. Co-authored-by: [Author Name] * [autofix.ci] apply automated fixes * Refactor position calculation in useFlowStore * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This pull request fixes an issue where there was potential overlap when pasting a copied selection. The commit adds a random factor to the x and y coordinates of the pasted selection, preventing overlap.