@@ -1152,7 +1152,7 @@ export class GridStack {
11521152 // check for css min height
11531153 let cssMinHeight = parseInt ( getComputedStyle ( this . el ) [ 'min-height' ] ) ;
11541154 if ( cssMinHeight > 0 ) {
1155- let minRow = Math . round ( cssMinHeight / this . getCellHeight ( ) ) ;
1155+ let minRow = Math . round ( cssMinHeight / this . getCellHeight ( true ) ) ;
11561156 if ( row < minRow ) {
11571157 row = minRow ;
11581158 }
@@ -1610,24 +1610,22 @@ export class GridStack {
16101610 }
16111611 } )
16121612 . on ( this . el , 'dropover' , ( event , el : GridItemHTMLElement ) => {
1613- let width , height ;
16141613
16151614 // see if we already have a node with widget/height and check for attributes
1616- let node = el . gridstackNode ;
1617- if ( ! node || ! node . width || ! node . height ) {
1615+ let node = el . gridstackNode || { } ;
1616+ if ( ! node . width || ! node . height ) {
16181617 let w = parseInt ( el . getAttribute ( 'data-gs-width' ) ) ;
1619- if ( w > 0 ) { node = node || { } ; node . width = w ; }
1618+ if ( w > 0 ) { node . width = w ; }
16201619 let h = parseInt ( el . getAttribute ( 'data-gs-height' ) ) ;
1621- if ( h > 0 ) { node = node || { } ; node . height = h ; }
1620+ if ( h > 0 ) { node . height = h ; }
16221621 }
16231622
16241623 // if not calculate the grid size based on element outer size
1625- let cellWidth = this . cellWidth ( ) ;
1626- let cellHeight = this . getCellHeight ( ) ;
1627- width = node && node . width ? node . width : Math . round ( el . offsetWidth / cellWidth ) || 1 ;
1628- height = node && node . height ? node . height : Math . round ( el . offsetHeight / cellHeight ) || 1 ;
1624+ let width = node . width || Math . round ( el . offsetWidth / this . cellWidth ( ) ) || 1 ;
1625+ let height = node . height || Math . round ( el . offsetHeight / this . getCellHeight ( true ) ) || 1 ;
16291626
1630- let newNode = this . engine . prepareNode ( { width, height, _added : false , _temporary : true } ) ;
1627+ // copy the node original values (min/max/id/etc...) but override width/height/other flags which are this grid specific
1628+ let newNode = this . engine . prepareNode ( { ...node , ...{ width, height, _added : false , _temporary : true } } ) ;
16311629 newNode . _isOutOfGrid = true ;
16321630 el . gridstackNode = newNode ;
16331631 el . _gridstackNodeOrig = node ;
@@ -1655,7 +1653,7 @@ export class GridStack {
16551653 . on ( this . el , 'drop' , ( event , el : GridItemHTMLElement , helper : GridItemHTMLElement ) => {
16561654 this . placeholder . remove ( ) ;
16571655
1658- // notify of removal from prev grid...
1656+ // notify previous grid of removal
16591657 let origNode = el . _gridstackNodeOrig ;
16601658 delete el . _gridstackNodeOrig ;
16611659 if ( origNode && origNode . grid && origNode . grid !== this ) {
@@ -1666,12 +1664,14 @@ export class GridStack {
16661664 oGrid . _triggerRemoveEvent ( ) ;
16671665 }
16681666
1669- let node : GridStackNode = el . gridstackNode ; // use existing placeholder node as it's already in our list with drop location
1670- this . engine . cleanupNode ( node ) ; // remove all internal _xyz values
1667+ let node = el . gridstackNode ; // use existing placeholder node as it's already in our list with drop location
1668+ const _id = node . _id ;
1669+ this . engine . cleanupNode ( node ) ; // removes all internal _xyz values (including the _id so add that back)
1670+ node . _id = _id ;
16711671 node . grid = this ;
16721672 this . dd . off ( el , 'drag' ) ;
16731673 // if we made a copy ('helper' which is temp) of the original node then insert a copy, else we move the original node (#1102)
1674- // as the helper will be nuked by default (by jqueryui and here to make it the same)
1674+ // as the helper will be nuked by jqueryui otherwise
16751675 if ( helper !== el ) {
16761676 helper . remove ( ) ;
16771677 el . gridstackNode = origNode ; // original item (left behind) is re-stored to pre dragging as the node now has drop info
@@ -1699,7 +1699,7 @@ export class GridStack {
16991699 }
17001700
17011701 // wait till we return out of the drag callback to set the new drag&resize handler or they may get messed up
1702- // IFF we are still there (soe application will use as placeholder and insert their real widget instead)
1702+ // IFF we are still there (some application will use as placeholder and insert their real widget instead)
17031703 window . setTimeout ( ( ) => {
17041704 if ( node . el && node . el . parentElement ) this . _prepareDragDropByNode ( node ) ;
17051705 } ) ;
0 commit comments