MrBlenny / react-flow-chart

🌊 A flexible, stateless, declarative flow chart library for react.
https://mrblenny.github.io/react-flow-chart/index.html
MIT License
1.48k stars 306 forks source link

Error when dragging nodes out of view. #135

Closed lukewarlow closed 4 years ago

lukewarlow commented 4 years ago

In the latest release (https://github.com/MrBlenny/react-flow-chart/releases/tag/0.0.12) if a node is dragged "offscreen" an "Unable to find node on an unmounted component." is triggered.

This only occurs when the node is dragged offscreen, not when the canvas is dragged. It can be reproduced on https://mrblenny.github.io/react-flow-chart/index.html?path=/story/sidebar--drag-and-drop by dragging the node behind the sidebar.

I've experienced this in my project as well as in the storybook. I've included a development stack trace below. Using version 0.0.11 I don't experience this issue.

Canvas scale is initialised to 1.

image

georginaso commented 4 years ago

@lukewarlow if you're not using the zoom feature (and an external state), I guess that it will be solved initializing the chart state with the scale attribute to "1".

e.g.


  offset: {
    x: 0,
    y: 0,
  },
  scale: 1,
  nodes: {},
  links: {},
  selected: {},
  hovered: {},
}
georginaso commented 4 years ago

The real bug is "Error when dragging nodes out of view if scale not set to '1'".

Maybe the canvas is not resizing 🤔?

Screenshot 2020-05-05 at 17 32 40
georginaso commented 4 years ago

You can reproduce this issue in the Storybook, setting a zoom in/out (easier to see with zoom out): https://mrblenny.github.io/react-flow-chart/index.html?path=/story/other-config--zoom

lukewarlow commented 4 years ago

I have this error with the chart scale set to 1. https://mrblenny.github.io/react-flow-chart/index.html?path=/story/sidebar--drag-and-drop it can be reproduced by dragging a node behind the sidebar. The rendering issue when zooming out is a separate issue.

georginaso commented 4 years ago

OK @lukewarlow ! I will create a new one. I thought that was the same because I have the same error --> "Unable to find node on an unmounted component."

lukewarlow commented 4 years ago

@georginaso they're potentially linked. I tried debugging older commits to see when it was introduced but none of them would let me build the storybook, so I've yet to identify the cause.

MrBlenny commented 4 years ago

I was getting the nodes not displaying but was not getting an error thrown. The display issue should be fixed here. https://github.com/MrBlenny/react-flow-chart/commit/cc7f02f02fa0a18dad5d304189e02bea36ad6535

lukewarlow commented 4 years ago

@MrBlenny this issue has not been fixed, this issue is related to dragging nodes out of view such as behind a sidebar.