-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Widget width reported incorrectly by save() after dragging from wider nested grid #2394
Comments
ha, good catch. |
The issue seems to stem from The comment at line 389 mentions my use case (the "target" grid has fewer columns than the "source" nested grid). I created a fork where I remove the added nodes from the layout cache when an add event is triggered. I'm not sure if this could cause issues in other use cases, but the width is reported correctly for me after this. |
* fix gridstack#2394] * better fix that makes sure we keep wanted size when an item is dropped on us (so we remember in case we change grid column) * also changed to not save x,y during dropping since the drag behavior will figure where to put it, and that means we don't cache that layout that might not apply to the new grid anyway. * added a running example showing issue.
Subject of the issue
Widget width is incorrect in JSON produced by the
save()
method, if the given widget has been dragged from a nested grid that has more columns than the outer grid. The grid and widgets behave correctly, the problem is only with data generated bysave()
. Loading back this data into the grid will cause an incorrect state (since the JSON contains an impossible layout)The
save()
method ingridstack-engine.ts
takes the width value fromthis._layouts
if present. The resized node's actual width seems correct, the incorrect value seems to come fromthis._layouts
https://github.com/gridstack/gridstack.js/blob/89ae9d6fd163137c5fde895ae14d1c5d2bb7a495/src/gridstack-engine.ts#L746C7-L746C7
Your environment
Steps to reproduce
The widget will have its width reported incorrectly in the JSON data generated by
save()
https://jsfiddle.net/akosfekete/Lpv2au4w/11/
Expected behavior
The width should be the same as it appears in the layout.
The text was updated successfully, but these errors were encountered: