File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -319,13 +319,15 @@ export class GridStackEngine {
319319 return node ;
320320 }
321321
322- public removeNode ( node : GridStackNode , removeDOM = true , triggerRemoveEvent = false ) : GridStackEngine {
323- if ( triggerRemoveEvent ) { // we wait until final drop to manually track removed items (rather than during drag)
322+ public removeNode ( node : GridStackNode , removeDOM = true , triggerEvent = false ) : GridStackEngine {
323+ if ( triggerEvent ) { // we wait until final drop to manually track removed items (rather than during drag)
324324 this . removedNodes . push ( node ) ;
325325 }
326326 node . _id = null ; // hint that node is being removed
327- this . nodes = this . nodes . filter ( n => n !== node ) ;
328- this . _packNodes ( ) ;
327+ this . nodes . splice ( this . nodes . findIndex ( n => n === node ) , 1 ) ;
328+ if ( ! this . float ) {
329+ this . _packNodes ( ) ;
330+ }
329331 this . _notify ( node , removeDOM ) ;
330332 return this ;
331333 }
Original file line number Diff line number Diff line change @@ -1214,10 +1214,11 @@ export class GridStack {
12141214 }
12151215
12161216 /** @internal prepares the element for drag&drop **/
1217- private _prepareElementsByNode ( el : GridItemHTMLElement , node : GridStackNode ) : GridStack {
1217+ private _prepareDragDropByNode ( node : GridStackNode ) : GridStack {
12181218 // variables used/cashed between the 3 start/move/end methods, in addition to node passed above
12191219 let cellWidth : number ;
12201220 let cellHeight : number ;
1221+ let el = node . el ;
12211222
12221223 /** called when item starts moving/resizing */
12231224 let onStartMoving = ( event , ui ) => {
@@ -1399,7 +1400,7 @@ export class GridStack {
13991400 node = this . engine . addNode ( node , triggerAddEvent ) ;
14001401 el . gridstackNode = node ;
14011402
1402- this . _prepareElementsByNode ( el , node ) ;
1403+ this . _prepareDragDropByNode ( node ) ;
14031404 return this ;
14041405 }
14051406
@@ -1699,7 +1700,10 @@ export class GridStack {
16991700 }
17001701
17011702 // wait till we return out of the drag callback to set the new drag&resize handler or they may get messed up
1702- window . setTimeout ( ( ) => this . _prepareElementsByNode ( el , node ) ) ;
1703+ // IFF we are still there (soe application will use as placeholder and insert their real widget instead)
1704+ window . setTimeout ( ( ) => {
1705+ if ( node . el && node . el . parentElement ) this . _prepareDragDropByNode ( node ) ;
1706+ } ) ;
17031707
17041708 return false ; // prevent parent from receiving msg (which may be grid as well)
17051709 } ) ;
You can’t perform that action at this time.
0 commit comments