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

Multiple controlled trees with live data loosing registered tree affecting drag and drop sometimes. #258

Open
CraigDeverall opened this issue Apr 27, 2023 · 2 comments
Assignees

Comments

@CraigDeverall
Copy link

Bug Description
When using multiple controlled trees that are driven by dynamic data and dragging and dropping on the first tree in dom. Sometimes the component can get into a state where the linearItems for the first tree are not present and this causes an error when dragging over items.

Uncaught TypeError: Cannot read properties of undefined (reading 'length')
at Object.eval [as current] (useOnDragOverTreeHandler.js:67:1)
at Object.eval [as onDragOverTreeHandler] (use-stable-handler.js:11:1)
at onDragOver (TreeManager.js:44:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
at invokeGuardedCallback (react-dom.development.js:4056:1)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)
at executeDispatch (react-dom.development.js:8243:1)
at processDispatchQueueItemsInOrder (react-dom.development.js:8275:1)
at processDispatchQueue (react-dom.development.js:8288:1)

In my case I am expecting a 'mainTree' (the first tree child) to also be present here:
image

I have tried and failed to checkout the repository and build react-complex-tree locally and link it to my project to debug unfortunately. I had wanted to investigate the setTimeout in UseControlledTreeEnvironmentProps.ts

image

To Reproduce

  • Use a ControlledTreeEnvironment.
  • Using live data from the database, changes in the tree save the data to backend and update the treeData passed to ControlledTreeEnvironment
  • I have 3 Tree components nested inside this ( all using different roots of the same data)
  • It doesn't happen initially, but after a subsequent render (ie change one of the treeRoots of the 2nd or 3rd trees and re-render after a item clicked action from the mainTree)
  • Drag and drop on the first child tree. Notice that it causes errors above.

Expected behaviour
That the mainTree linearItems would still be there and that this error wouldn't occur in this situation.

On MacbookPro using Chrome.

Unfortunately I can't share my exact code, I will try to spend some time reproduce this in a sandbox.

@CraigDeverall
Copy link
Author

Another clue I noticed is that prior to this happening there is an 'undefined' tree unregistered.
I could see this after logging like this:
image

@lukasbach
Copy link
Owner

Hey, thanks for your report! Can you provide maybe an "anonymized" version of the code that creates the RCT instance, i.e. the react components for the tree and the tree environment? To me it looks like there are some inconsistencies in how the tree IDs are maintained by or provided to RCT.

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

2 participants