Skip to content

Commit f2f3189

Browse files
authored
Merge pull request #3110 from adumesny/master
correctly reset widget back
2 parents 7a92850 + 13680fc commit f2f3189

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

demo/two_vertical.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1>Two vertical grids demo - with maxRow</h1>
2626
acceptWidgets: true
2727
}
2828
GridStack.init(opts, document.getElementById('grid1'))
29-
.load([{x:0, y:0, content: '0'}, {x:1, y:0, content: '1'}]);
29+
.load([{x:1, y:0, content: '0'}, {x:2, y:0, content: '1'}]);
3030
GridStack.init(opts, document.getElementById('grid2'))
3131
.load([{x:0, y:0, content: '2'}, {x:1, y:0, content: '3'}]);
3232
</script>

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ Change log
135135
* fix: [#3099](https://github.com/gridstack/gridstack.js/issues/3099) scroll take into account ScrollContainer position
136136
* fix: [#3102](https://github.com/gridstack/gridstack.js/pull/3102) React demo now support multiple grids
137137
* fix: [#3047](https://github.com/gridstack/gridstack.js/issues/3047) added `.grid-stack-dragging` to grid when child is being dragged so we can set cursor:grabbing, updated demo.
138+
* fix: [#3021](https://github.com/gridstack/gridstack.js/issues/3021) correctly reset widget back (to last known position) when released outside
138139

139140
## 12.2.2 (2025-07-06)
140141
* fix: [#3070](https://github.com/gridstack/gridstack.js/pull/3070) incorrect property name 'sizeToContent' when cleaning up invalid attributes

src/gridstack.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ export class GridStack {
553553
if (nodeToAdd?._moving) subGrid._isTemp = true; // prevent re-nesting as we add over
554554
if (autoColumn) subGrid._autoColumn = true;
555555

556-
// add the original content back as a child of hte newly created grid
556+
// add the original content back as a child of the newly created grid
557557
if (saveContent) {
558558
subGrid.makeWidget(newItem, newItemOpt);
559559
}
@@ -2424,8 +2424,7 @@ export class GridStack {
24242424
} else {
24252425
Utils.removePositioningStyles(target);
24262426
if (node._temporaryRemoved) {
2427-
// got removed - restore item back to before dragging position
2428-
Utils.copyPos(node, node._orig);// @ts-ignore
2427+
// use last position we were at (not _orig as we may have pushed others and moved) and add it back
24292428
this._writePosAttr(target, node);
24302429
this.engine.addNode(node);
24312430
} else {

0 commit comments

Comments
 (0)