Skip to content

Conversation

@akosfekete
Copy link
Contributor

Description

Fix #2394 by removing dropped nodes from GridstackEngine's layout cache.
I checked 1985_read_1_column_wrong_12.html (the code relevant here has been added in that PR) and the behaviour is the same as before. Nodes are still positioned correctly after initialising in one column mode, and then enlarging the window (no matter how they are added)

Checklist

  • Created tests which fail without the change (if possible)
  • All tests passing (yarn test)
  • Extended the README / documentation, if necessary

this._updateContainerHeight();
this.engine.addedNodes.push(node);// @ts-ignore
this._triggerAddEvent();// @ts-ignore
this.engine.removeNodeFromLayoutCache(node);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't make sense to me as new grid target should not have that node to start with in it's cache.
instead line 2092 oGrid.engine.removeNodeFromLayoutCache(node); should be called to remove when LEAVING that grid.
I'll pull your changes and make the correct fix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind I stand corrected. the issue is dropping an item that is larger into a grid - should it remember the width it wants to be and reloading should handle out of bound sizes (that is a bug) ? visually you are mathcing the wanted size but it w=2 outer grid vs w=3 inner grid. sicne it's a drag we visually match them (closest possible) so I'm ok with dropping the original width.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem with your fix is that if an item wants to be w=3 (from sidebar with attributes values) but dropped into a 1 column, then you will forever loose the fact it wants to get widget if grid ever goes to 2,3,4 columns

the real fix is to make sure loading w=3 into a subgrip does the right thing - which IT DOES in v9.2.1 I tested with my example (based on your bug). So I will remove it.

@adumesny adumesny merged commit 1ff1f42 into gridstack:master Sep 27, 2023
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.

Widget width reported incorrectly by save() after dragging from wider nested grid

2 participants