@@ -2215,6 +2215,12 @@ export class GridStack {
22152215 return false ; // prevent parent from receiving msg (which may be a grid as well)
22162216 }
22172217
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+
22182224 // fix #1578 when dragging fast, we may not get a leave on the previous grid so force one now
22192225 if ( node ?. grid && node . grid !== this && ! node . _temporaryRemoved ) {
22202226 // console.log('dropover without leave'); // TEST
@@ -2227,7 +2233,7 @@ export class GridStack {
22272233 cellWidth = this . cellWidth ( ) ;
22282234 cellHeight = this . getCellHeight ( true ) ;
22292235
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
22312237 if ( ! node ) {
22322238 const attr = helper . getAttribute ( 'data-gs-widget' ) || helper . getAttribute ( 'gridstacknode' ) ; // TBD: temp support for old V11.0.0 attribute
22332239 if ( attr ) {
@@ -2240,6 +2246,8 @@ export class GridStack {
22402246 helper . removeAttribute ( 'gridstacknode' ) ;
22412247 }
22422248 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 }
22432251 }
22442252 if ( ! node . grid ) { // sidebar item
22452253 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 {
26612669 this . _updateContainerHeight ( ) ;
26622670
26632671 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+ }
26652676 if ( this . _gsEventHandler [ event . type ] ) {
26662677 this . _gsEventHandler [ event . type ] ( event , target ) ;
26672678 }
@@ -2687,7 +2698,10 @@ export class GridStack {
26872698
26882699 this . engine . removeNode ( node ) ; // remove placeholder as well, otherwise it's a sign node is not in our list, which is a bigger issue
26892700 node . el = node . _isExternal && helper ? helper : el ; // point back to real item being dragged
2701+ const sidebarOrig = node . _sidebarOrig ;
26902702 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 ;
26912705
26922706 if ( this . opts . removable === true ) { // boolean vs a class string
26932707 // item leaving us and we are supposed to remove on leave (no need to drag onto trash) mark it so
0 commit comments