-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: prevent infinite loop while splitting pages #2822
Conversation
🦋 Changeset detectedLatest commit: 36f1e75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Change seems correct to me (who wrote the current splitting algorithm), thanks for fixing this! I don't have time to test it manually, unfortunately.
Thanks for this. Unfortunately I have very little time lately and can't test right now. Can someone validate it? 🙏🏻 |
@diegomura can this be merged/released? |
Would be awesome to release because this is probably the reason why our scenario does not work as well and page is crashing all the time |
@mantljosh could you help install your version locally and make it as a permanent dependency? I am not strict front-end dev but I hope that your fix could solve lots of issues we have |
The existing check for whether all children got moved the next page makes sense if we're already partly through the page - but if this happens before we have anything in
currentChildren
then we'll essentially leave a blank page and move everything to the "next" page, which results in an infinite loop (since the next page never gets smaller).This PR checks for this situation, and in this case will add the current node to the current page and push the remaining nodes to the next page. This ensures that the next page will get smaller by at least one node so that future iteration won't infinitely loop.
I added a test case that reproduces it - the test doesn't fail it will just hang forever, but if it doesn't loop then the test will pass successfully.
Fixes #2659