Thanks to visit codestin.com
Credit goes to github.com

Skip to content

empty addedNodes and removedNodes before triggering event to prevent infinite loop #2617

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

Merged
merged 1 commit into from
Feb 17, 2024

Conversation

galizhur
Copy link
Contributor

If you call addWidget inside the grid added or removed events, the items passed in the event for the

Calling addWidget inside the "added" event triggers another "added" event with the items argument containing the newly added item and the initial item that triggered the first added event. The second "added" event should contain only the newly added item.

This happens because the "added" event is triggerd first and the internal addedNodes array is emptied afterwards. The fix was to empty the addedNodes array before triggering the "added" event.

The same happens when calling removeWidget inside the "removed" event.

@adumesny
Copy link
Member

would be great if you didn't reformat/pretty the existing code...

@adumesny adumesny merged commit d9639ec into gridstack:master Feb 17, 2024
@galizhur
Copy link
Contributor Author

would be great if you didn't reformat/pretty the existing code...

yeah. sorry about that. i didn't notice there were so many reformats :(

@galizhur galizhur deleted the bug/added_remove_nodes_cleanup branch February 24, 2024 06:35
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

Successfully merging this pull request may close these issues.

2 participants