Skip to content
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

Node drag versus canvas resize #279

Open
direvus opened this issue Sep 27, 2024 · 2 comments
Open

Node drag versus canvas resize #279

direvus opened this issue Sep 27, 2024 · 2 comments

Comments

@direvus
Copy link

direvus commented Sep 27, 2024

Describe the bug

I have a reagraph component that users can toggle between two different sizes (normal and enlarged). This works fine except when repositioning nodes with draggable={true}.

Dragging nodes in the original size works as expected.

Flipping to the other size and dragging nodes causes the nodes to suddenly jump vertically by hundreds of pixels. They continue to drag correctly in the x-axis but remain massively offset from the cursor position in the y-axis.

Return to the original size, and everything is working as expected again.

It seems like the reagraph component is caching the height of the canvas internally and not updating its drag logic when that height changes.

I have tried forcing an update of the nodes state with a useEffect when the size of the graph is switched, but that didn't help.

Is there anything I can do to work around this?

Steps to Reproduce the Bug or Issue

  1. Create a React application with a reagraph component, enclosed in a div that can be resized by controlling a state variable.
  2. Enable draggable on the GraphCanvas
  3. Confirm that nodes can be repositioned by dragging in the normal size mode
  4. Change the size mode and try repositioning nodes again

Expected behavior

I expect that dragging nodes will work correctly after updating the size of the GraphCanvas.

Instead, after updating the size of the GraphCanvas, nodes get flung off to a distant y-value when I drag them.

Screenshots or Videos

No response

Platform

  • Reagraph Version: ^4.19.3
  • OS: Ubuntu 22.04
  • Browser: Firefox
  • NodeJS version: 20.16.0

Your Example Website or App

No response

Additional context

I will try to work up a minimal example in Codesandbox and update this issue when it's ready.

@direvus
Copy link
Author

direvus commented Sep 27, 2024

Codesandbox example can be seen here: https://codesandbox.io/p/devbox/react-ts-9qputt

@direvus
Copy link
Author

direvus commented Sep 27, 2024

reagraph-node-dragging-glitch.mp4

Here's a screencast demonstrating the problem.

Somehow this minimal example is actually worse than my real application. The dragging is janked in both the original size and the enlarged size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant