diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 6f29b6bcc..12e0829bf 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.1.1 (2024-03-03)](#1011-2024-03-03) - [10.1.0 (2024-02-04)](#1010-2024-02-04) - [10.0.1 (2023-12-10)](#1001-2023-12-10) - [10.0.0 (2023-11-20)](#1000-2023-11-20) @@ -106,6 +107,8 @@ Change log - [v0.1.0 (2014-11-18)](#v010-2014-11-18) +## 10.1.1 (2024-03-03) +* fix: [#2620](https://github.com/gridstack/gridstack.js/pull/2620) allow resizing with sizeToContent:NUMBER is uses ## 10.1.0 (2024-02-04) * feat: [#2574](https://github.com/gridstack/gridstack.js/pull/2574) Allow cell height in cm and mm units diff --git a/src/dd-gridstack.ts b/src/dd-gridstack.ts index 254e02db2..4a777017e 100644 --- a/src/dd-gridstack.ts +++ b/src/dd-gridstack.ts @@ -46,7 +46,7 @@ export class DDGridStack { if (handles === 'all') handles = 'n,e,s,w,se,sw,ne,nw'; // NOTE: keep the resize handles as e,w don't have enough space (10px) to show resize corners anyway. limit during drag instead // restrict vertical resize if height is done to match content anyway... odd to have it spring back - // if (Utils.shouldSizeToContent(n)) { + // if (Utils.shouldSizeToContent(n, true)) { // const doE = handles.indexOf('e') !== -1; // const doW = handles.indexOf('w') !== -1; // handles = doE ? (doW ? 'e,w' : 'e') : (doW ? 'w' : ''); diff --git a/src/dd-resizable.ts b/src/dd-resizable.ts index a512cdb59..3d71012d6 100644 --- a/src/dd-resizable.ts +++ b/src/dd-resizable.ts @@ -166,7 +166,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt /** @internal */ protected _resizeStart(event: MouseEvent): DDResizable { - this.sizeToContent = Utils.shouldSizeToContent(this.el.gridstackNode); + this.sizeToContent = Utils.shouldSizeToContent(this.el.gridstackNode, true); // strick true only and not number this.originalRect = this.el.getBoundingClientRect(); this.scrollEl = Utils.getScrollElement(this.el); this.scrollY = this.scrollEl.scrollTop; diff --git a/src/utils.ts b/src/utils.ts index e68d80f86..6d7d46e24 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -109,9 +109,11 @@ export class Utils { return els; } - /** true if we should resize to content */ - static shouldSizeToContent(n: GridStackNode | undefined): boolean { - return n?.grid && (!!n.sizeToContent || (n.grid.opts.sizeToContent && n.sizeToContent !== false)); + /** true if we should resize to content. strict=true when only 'sizeToContent:true' and not a number which lets user adjust */ + static shouldSizeToContent(n: GridStackNode | undefined, strict = false): boolean { + return n?.grid && (strict ? + (n.sizeToContent === true || (n.grid.opts.sizeToContent === true && n.sizeToContent === undefined)) : + (!!n.sizeToContent || (n.grid.opts.sizeToContent && n.sizeToContent !== false))); } /** returns true if a and b overlap */