Skip to content

[BUG] New widgets added by .load() displace existing widgets #2639

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

Closed
jilow opened this issue Mar 26, 2024 · 3 comments · Fixed by #2644
Closed

[BUG] New widgets added by .load() displace existing widgets #2639

jilow opened this issue Mar 26, 2024 · 3 comments · Fixed by #2644
Labels

Comments

@jilow
Copy link

jilow commented Mar 26, 2024

Subject of the issue

New widgets created by the .load() method are rendered in the middle of the grid and displace existing widgets.

This behavior doesn't match .addWidget() which places new widgets in the next available slot without displacing.

Screenshots

.addWidget(newItem) .load(items + newItem)
image image

Your environment

Version: 10.0.1 & 10.1.1
Browser/OS: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:124.0) Gecko/20100101 Firefox/124.0

Steps to reproduce

Demo: https://jsfiddle.net/2g4zarb8/

  1. Create a new node with auto position (no w or h).
  2. Add the widget using .addWidget() and observe it in the next open horizontal spot.
  3. Add the same widget using .load() and observe it in the middle of the grid.

Expected behavior

New widgets are placed consistently regardless of which method was used. In this case I'd expect new widget added with .load() to be placed in the same location .addWidget() would.

@adumesny
Copy link
Member

adumesny commented Mar 27, 2024

yeah, that case should work but load() was written expecting complete layouts (doing just the diffs) but since that item is new it should addWidget() at the end since there is no location... special case.

adumesny added a commit to adumesny/gridstack.js that referenced this issue Mar 30, 2024
* fix gridstack#2639
* make sure we separate out new item that don't have coordinates to be added afterward
@adumesny
Copy link
Member

fixed in the next release. don't forget to donate if you find this lib useful!

@jilow
Copy link
Author

jilow commented Apr 2, 2024

Thanks for fixing this so quickly @adumesny! I can confirm that this is no longer an issue as of v10.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants