diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 6e87a587d..ceb6bbc50 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/)* +- [10.3.0-dev (TBD)](#1030-dev-tbd) - [10.3.0 (2024-06-26)](#1030-2024-06-26) - [10.2.1 (2024-06-23)](#1021-2024-06-23) - [10.2.0 (2024-06-02)](#1020-2024-06-02) @@ -112,6 +113,9 @@ Change log +## 10.3.0-dev (TBD) +* fix: [#2734](https://github.com/gridstack/gridstack.js/bug/2734) rotate() JS error + ## 10.3.0 (2024-06-26) * fix: [#2720](https://github.com/gridstack/gridstack.js/pull/2720) load() now creates widgets in order (used to be reverse due to old collision code) diff --git a/src/gridstack.ts b/src/gridstack.ts index cf9ee6aae..f7162fe7c 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -1447,7 +1447,10 @@ export class GridStack { rot.x = n.x + pivotX - (n.h - (pivotY+1)); rot.y = (n.y + pivotY) - pivotX; } + Object.keys(rot).forEach(k => { if (rot[k] === undefined) delete rot[k]; }); + const _orig = n._orig; this.update(el, rot); + n._orig = _orig; // restore as move() will delete it }); return this; } diff --git a/src/utils.ts b/src/utils.ts index 748f25dee..33bf8fa0a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -590,7 +590,10 @@ export class Utils { } /** swap the given object 2 field values */ - public static swap(o: unknown, a: string, b: string): void { const tmp = o[a]; o[a] = o[b]; o[b] = tmp; } + public static swap(o: unknown, a: string, b: string): void { + if (!o) return; + const tmp = o[a]; o[a] = o[b]; o[b] = tmp; + } /** returns true if event is inside the given element rectangle */ // Note: Safari Mac has null event.relatedTarget which causes #1684 so check if DragEvent is inside the coordinates instead