@@ -1238,24 +1238,24 @@ export class GridStack {
1238
1238
let distance = ui . position . top - node . _prevYPix ;
1239
1239
node . _prevYPix = ui . position . top ;
1240
1240
Utils . updateScrollPosition ( el , ui . position , distance ) ;
1241
- if ( el . dataset . inTrashZone || x < 0 || x >= this . engine . column || y < 0 ||
1242
- ( ! this . engine . float && y > this . engine . getRow ( ) ) ) {
1243
- if ( ! node . _temporaryRemoved ) {
1244
- if ( this . opts . removable === true ) {
1245
- this . _setupRemovingTimeout ( el ) ;
1246
- }
1247
-
1248
- x = node . _beforeDragX ;
1249
- y = node . _beforeDragY ;
1241
+ // if inTrash, outside of the bounds or added to another grid (#393) temporarily remove it from us
1242
+ if ( el . dataset . inTrashZone || x < 0 || x >= this . engine . column || y < 0 || ( ! this . engine . float && y > this . engine . getRow ( ) ) || node . _added ) {
1243
+ if ( node . _temporaryRemoved ) { return ; }
1244
+ if ( this . opts . removable === true ) {
1245
+ this . _setupRemovingTimeout ( el ) ;
1246
+ }
1250
1247
1251
- if ( this . placeholder . parentNode === this . el ) { this . el . removeChild ( this . placeholder ) }
1252
- this . engine . removeNode ( node ) ;
1253
- this . _updateContainerHeight ( ) ;
1248
+ x = node . _beforeDragX ;
1249
+ y = node . _beforeDragY ;
1254
1250
1255
- node . _temporaryRemoved = true ;
1256
- } else {
1257
- return ;
1251
+ if ( this . placeholder . parentNode === this . el ) {
1252
+ this . placeholder . remove ( ) ;
1258
1253
}
1254
+ this . engine . removeNode ( node ) ;
1255
+ this . _updateContainerHeight ( ) ;
1256
+
1257
+ node . _temporaryRemoved = true ;
1258
+ delete node . _added ; // no need for this now
1259
1259
} else {
1260
1260
this . _clearRemovingTimeout ( el ) ;
1261
1261
@@ -1290,7 +1290,9 @@ export class GridStack {
1290
1290
1291
1291
/** called when the item stops moving/resizing */
1292
1292
let onEndMoving = ( event : Event ) => {
1293
- if ( this . placeholder . parentNode === this . el ) { this . el . removeChild ( this . placeholder ) }
1293
+ if ( this . placeholder . parentNode === this . el ) {
1294
+ this . placeholder . remove ( ) ;
1295
+ }
1294
1296
1295
1297
// if the item has moved to another grid, we're done here
1296
1298
let target : GridItemHTMLElement = event . target as GridItemHTMLElement ;
@@ -1620,6 +1622,11 @@ export class GridStack {
1620
1622
if ( h > 0 ) { node . height = h ; }
1621
1623
}
1622
1624
1625
+ // if the item came from another grid, let it know it was added here to removed duplicate shadow #393
1626
+ if ( node . grid && node . grid !== this ) {
1627
+ node . _added = true ;
1628
+ }
1629
+
1623
1630
// if not calculate the grid size based on element outer size
1624
1631
let width = node . width || Math . round ( el . offsetWidth / this . cellWidth ( ) ) || 1 ;
1625
1632
let height = node . height || Math . round ( el . offsetHeight / this . getCellHeight ( true ) ) || 1 ;
@@ -1644,7 +1651,7 @@ export class GridStack {
1644
1651
node . el = null ;
1645
1652
this . engine . removeNode ( node ) ;
1646
1653
if ( this . placeholder . parentNode === this . el ) {
1647
- this . el . removeChild ( this . placeholder ) ;
1654
+ this . placeholder . remove ( ) ;
1648
1655
}
1649
1656
this . _updateContainerHeight ( ) ;
1650
1657
el . gridstackNode = el . _gridstackNodeOrig ;
0 commit comments