Closed dsoklic closed 1 month ago
@dsoklic I can't open your sandbox. If you update it, I can take a look
@peterkogo Sorry, I didn't change the permissions to the sandbox. Could you try it again?
Any updates?
Hey, could you check with the latest v12 release?
@moklick I tried it out with the latest v12, and I still get this issue. It required some more selecting and unselecting, but eventually, I got the same error. Link to the sandbox: link
In another issue the guy advised making the state immutable
https://github.com/xyflow/xyflow/issues/2240
@dsoklic thanks for the codesandbox! I can't repro it with v12 there 🤔
@moklick I recorded a video, so you can see what steps I did: video
Sometimes you need to keep selecting and unselecting for a while to get this error. In my video, it just coincidentally happened so fast.
@dsoklic thanks, now I get it too. I will check it!
The reason for this bug is the onSelectionChange
handler. Will be fixed in the next release - for now you can can remove the handler and it should work as expected.
When will the next release be? And what will be the title of the release? 11.11.2?
Fixed in 11.11.2 and 12.0.0-next.15
I still get this error even after installing 11.11.2
I found a solution for preventing this error, but it looks not good. Look at the commented code.
Describe the Bug
I'm using Redux Toolkit for my application. When I select a few nodes by drawing a rectangle, I get the exception that says: Cannot assign to read only property 'selected' of object '#
This issue happens because Redux Toolkit uses Immer under the hood, but React-flow tries to mutate the data. I was able to track down the issue to the
getSelectionChanges
function, where the selected property is mutated.I tested this on React-flow v11.10.1 and v12, it happens with both.
Your Example Website or App
https://codesandbox.io/p/sandbox/selection-with-redux-reactflow11-mkd4ql
Steps to Reproduce the Bug or Issue
Very soon you should get the exception.
Expected behavior
No exception should be thrown
Screenshots or Videos
No response
Platform
Additional context
Seems to be related to https://github.com/xyflow/xyflow/issues/2170