From 77936c24562f7009a35ca360721c3fdf3264140f Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Fri, 8 Sep 2023 07:35:55 -0700 Subject: [PATCH] full grid maxRow fix * fix #2449 * move, while still being under maxRow or at least not making it worse (case where widget was somehow added past our max) --- doc/CHANGES.md | 4 ++++ src/gridstack-engine.ts | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 27aea53cf..36fb825f0 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -5,6 +5,7 @@ Change log **Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)* +- [9.1.1-dev (TBD)](#911-dev-tbd) - [9.1.1 (2023-09-06)](#911-2023-09-06) - [9.1.0 (2023-09-04)](#910-2023-09-04) - [9.0.2 (2023-08-29)](#902-2023-08-29) @@ -97,6 +98,9 @@ Change log +## 9.1.1-dev (TBD) +* fix [#2449](https://github.com/gridstack/gridstack.js/issues/2449) full grid maxRow fix + ## 9.1.1 (2023-09-06) * fix [#2435](https://github.com/gridstack/gridstack.js/issues/2435) directionCollideCoverage() tweaks * fix resizeToContent() to handle node.h (using when cellHeight changes or we resize) vs DOM sizing (rest of the time) diff --git a/src/gridstack-engine.ts b/src/gridstack-engine.ts index b6b234705..6f193edab 100644 --- a/src/gridstack-engine.ts +++ b/src/gridstack-engine.ts @@ -591,8 +591,9 @@ export class GridStackEngine { }); if (!clonedNode) return false; - // check if we're covering 50% collision and could move - let canMove = clone.moveNode(clonedNode, o) && clone.getRow() <= this.maxRow; + // check if we're covering 50% collision and could move, while still being under maxRow or at least not making it worse + // (case where widget was somehow added past our max #2449) + let canMove = clone.moveNode(clonedNode, o) && clone.getRow() <= Math.max(this.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%