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

Incorrectly placed item after repeated insertion and deletion of a column #2576

Closed
vmerz-mgy opened this issue Dec 14, 2023 · 5 comments · Fixed by #2581 · May be fixed by Samg217/glpi#8
Closed

Incorrectly placed item after repeated insertion and deletion of a column #2576

vmerz-mgy opened this issue Dec 14, 2023 · 5 comments · Fixed by #2581 · May be fixed by Samg217/glpi#8

Comments

@vmerz-mgy
Copy link

Subject of the issue

If you add and remove columns twice, an item is displayed in the wrong column

Your environment

  • Gridstack 10.0.1
  • Safari Version 17.1.2 / Chrome Version 120.0.6099.71 / MacOS Monterey

Steps to reproduce

Watching the example says more than a thousand words ;)
Click buttons as described here
https://jsfiddle.net/vmerz/fxag04cL/151/

Expected behavior

Item 2 should stay in column 4 (zero-based)

@adumesny
Copy link
Member

adumesny commented Dec 17, 2023

FYI, instead of

return grid.getGridItems().filter(item => {
       const node = item.gridstackNode;
       return node 
         && node.x !== undefined 
         && node.x !== null 
         && node.x >= x;
   });

you can just use return grid.engine.nodes.filter(n => n.x >= x)

you got me intrigued... here is a cleaner copy with some fix
https://jsfiddle.net/adumesny/mk2ynzet/

@vmerz-mgy
Copy link
Author

Great - thank you very much for the suggestions for improvement and the advice on filtering

@adumesny
Copy link
Member

Updated my link: the problem has to do I believe with having that 5 column layout stored in memory and when going back using that instead of using 'none' to skip any sort of layout.

This is likely not an easy fix (when you modify items in say 4 column, it tries to update the layout in other columns) and will require a donation if you want me to debug this further... or work around doing a load() of pre-computed values instead.

@adumesny
Copy link
Member

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

adumesny added a commit to adumesny/gridstack.js that referenced this issue Dec 18, 2023
@vmerz-mgy
Copy link
Author

Many thanks for the quick processing of the issue. In my next code review I will focus on an even stricter separation of concerns in my application, maybe this will be a good start for a vue-wrapper and I can contribute a small part to the project.

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