@@ -2215,6 +2215,12 @@ export class GridStack {
2215
2215
return false ; // prevent parent from receiving msg (which may be a grid as well)
2216
2216
}
2217
2217
2218
+ // If sidebar item, restore the sidebar node size to ensure consistent behavior when dragging between grids
2219
+ if ( node ?. _sidebarOrig ) {
2220
+ node . w = node . _sidebarOrig . w ;
2221
+ node . h = node . _sidebarOrig . h ;
2222
+ }
2223
+
2218
2224
// fix #1578 when dragging fast, we may not get a leave on the previous grid so force one now
2219
2225
if ( node ?. grid && node . grid !== this && ! node . _temporaryRemoved ) {
2220
2226
// console.log('dropover without leave'); // TEST
@@ -2227,7 +2233,7 @@ export class GridStack {
2227
2233
cellWidth = this . cellWidth ( ) ;
2228
2234
cellHeight = this . getCellHeight ( true ) ;
2229
2235
2230
- // sidebar items: load any element attributes if we don't have a node
2236
+ // sidebar items: load any element attributes if we don't have a node on first enter from the sidebar
2231
2237
if ( ! node ) {
2232
2238
const attr = helper . getAttribute ( 'data-gs-widget' ) || helper . getAttribute ( 'gridstacknode' ) ; // TBD: temp support for old V11.0.0 attribute
2233
2239
if ( attr ) {
@@ -2240,6 +2246,8 @@ export class GridStack {
2240
2246
helper . removeAttribute ( 'gridstacknode' ) ;
2241
2247
}
2242
2248
if ( ! node ) node = this . _readAttr ( helper ) ; // used to pass false for #2354, but now we clone top level node
2249
+ // On first grid enter from sidebar, set the initial sidebar item size properties for the node
2250
+ node . _sidebarOrig = { w : node . w , h : node . h }
2243
2251
}
2244
2252
if ( ! node . grid ) { // sidebar item
2245
2253
if ( ! node . el ) node = { ...node } ; // clone first time we're coming from sidebar (since 'clone' doesn't copy vars)
@@ -2661,7 +2669,10 @@ export class GridStack {
2661
2669
this . _updateContainerHeight ( ) ;
2662
2670
2663
2671
const target = event . target as GridItemHTMLElement ; // @ts -ignore
2664
- this . _writePosAttr ( target , node ) ;
2672
+ // Do not write sidebar item attributes back to the original sidebar el
2673
+ if ( ! node . _sidebarOrig ) {
2674
+ this . _writePosAttr ( target , node ) ;
2675
+ }
2665
2676
if ( this . _gsEventHandler [ event . type ] ) {
2666
2677
this . _gsEventHandler [ event . type ] ( event , target ) ;
2667
2678
}
@@ -2687,7 +2698,10 @@ export class GridStack {
2687
2698
2688
2699
this . engine . removeNode ( node ) ; // remove placeholder as well, otherwise it's a sign node is not in our list, which is a bigger issue
2689
2700
node . el = node . _isExternal && helper ? helper : el ; // point back to real item being dragged
2701
+ const sidebarOrig = node . _sidebarOrig ;
2690
2702
if ( node . _isExternal ) this . engine . cleanupNode ( node ) ;
2703
+ // Restore sidebar item initial size info to stay consistent when dragging between multiple grids
2704
+ node . _sidebarOrig = sidebarOrig ;
2691
2705
2692
2706
if ( this . opts . removable === true ) { // boolean vs a class string
2693
2707
// item leaving us and we are supposed to remove on leave (no need to drag onto trash) mark it so
0 commit comments