Skip to content

Commit

Permalink
fix gridstack#2055 maxRow=1 resize outside
Browse files Browse the repository at this point in the history
* fix bug introduced when fixing gridstack#2043 (checking for 50% coverage before swap)
  • Loading branch information
adumesny committed Oct 8, 2022
1 parent a1b1bf7 commit 3c447eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions doc/CHANGES.md
Expand Up @@ -5,6 +5,7 @@ Change log
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*

- [6.0.2-dev (TBD)](#602-dev-tbd)
- [6.0.2 (2022-09-23)](#602-2022-09-23)
- [6.0.1 (2022-08-27)](#601-2022-08-27)
- [6.0.0 (2022-08-21)](#600-2022-08-21)
Expand Down Expand Up @@ -71,6 +72,9 @@ Change log

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## 6.0.2-dev (TBD)
* fixed [#2055](https://github.com/gridstack/gridstack.js/issues/2055) maxRow=1 resize outside

## 6.0.2 (2022-09-23)
* fixed [#2034](https://github.com/gridstack/gridstack.js/issues/2034) `removeWidget()` breaking resize handle feedback
* fixed [#2043](https://github.com/gridstack/gridstack.js/issues/2043) when swapping shapes in maxRow grid, make sure we still check for 50% coverage
Expand Down
8 changes: 4 additions & 4 deletions src/gridstack-engine.ts
Expand Up @@ -543,10 +543,10 @@ export class GridStackEngine {
if (!clonedNode) return false;

// check if we're covering 50% collision and could move
let canMove = clone.moveNode(clonedNode, o);
// make sure we are still valid grid max, else check if we can force a swap (float=true, or different shapes) on non-resize
if (!o.resizing && canMove && o.collide && this.float && clone.getRow() > this.maxRow) {
let collide = o.collide.el.gridstackNode; // find the source node the clone collided with
let canMove = clone.moveNode(clonedNode, o) && clone.getRow() <= this.maxRow;
// else check if we can force a swap (float=true, or different shapes) on non-resize
if (!canMove && !o.resizing && o.collide) {
let collide = o.collide.el.gridstackNode; // find the source node the clone collided with at 50%
if (this.swap(node, collide)) { // swaps and mark dirty
this._notify();
return true;
Expand Down

0 comments on commit 3c447eb

Please sign in to comment.