Remove added node from layout cache on drop event#2461
Conversation
| this._updateContainerHeight(); | ||
| this.engine.addedNodes.push(node);// @ts-ignore | ||
| this._triggerAddEvent();// @ts-ignore | ||
| this.engine.removeNodeFromLayoutCache(node); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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
yarn test)