From 22ec93a5eca5a82a4367c4d201c3641ebe31eb97 Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Sun, 8 Dec 2024 18:22:24 -0800 Subject: [PATCH] added `gs-size-to-content` support * fix #2886 * untested but should be fine :) --- doc/CHANGES.md | 5 +++++ src/gridstack.ts | 3 +++ src/types.ts | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 0b8df831..03f8a2b6 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/)* +- [11.1.1-dev (TBD)](#1111-dev-tbd) - [11.1.1 (2024-11-26)](#1111-2024-11-26) - [11.1.0 (2024-11-17)](#1110-2024-11-17) - [11.0.1 (2024-10-21)](#1101-2024-10-21) @@ -117,6 +118,10 @@ Change log +## 11.1.1-dev (TBD) +* fix: [#2877](https://github.com/gridstack/gridstack.js/pull/2877) angular wrapper uses standalone, while now being compatible down to ng14. thanks to [andre-steudel](https://github.com/andre-steudel) +* fix: [#2886](https://github.com/gridstack/gridstack.js/issues/2886) added `gs-size-to-content` support + ## 11.1.1 (2024-11-26) * fix: [#2878](https://github.com/gridstack/gridstack.js/pull/2878) make sure sub-grid inherit parent opts by default, with subgrid defaults. * fix: [#2879](https://github.com/gridstack/gridstack.js/pull/2879) sub-grid item `sizeToContent:true` now handle content above/below sub grid. diff --git a/src/gridstack.ts b/src/gridstack.ts index 9bd54b9f..096d2e72 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -333,6 +333,7 @@ export class GridStack { minRow: rowAttr ? rowAttr : Utils.toNumber(el.getAttribute('gs-min-row')) || gridDefaults.minRow, maxRow: rowAttr ? rowAttr : Utils.toNumber(el.getAttribute('gs-max-row')) || gridDefaults.maxRow, staticGrid: Utils.toBool(el.getAttribute('gs-static')) || gridDefaults.staticGrid, + sizeToContent: Utils.toBool(el.getAttribute('gs-size-to-content')) || undefined, draggable: { handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) || gridDefaults.draggable.handle, }, @@ -1719,6 +1720,7 @@ export class GridStack { noMove: 'gs-no-move', locked: 'gs-locked', id: 'gs-id', + sizeToContent: 'gs-size-to-content', }; for (const key in attrs) { if (node[key]) { // 0 is valid for x,y only but done above already and not in list anyway @@ -1741,6 +1743,7 @@ export class GridStack { n.noResize = Utils.toBool(el.getAttribute('gs-no-resize')); n.noMove = Utils.toBool(el.getAttribute('gs-no-move')); n.locked = Utils.toBool(el.getAttribute('gs-locked')); + n.sizeToContent = Utils.toBool(el.getAttribute('gs-size-to-content')); n.id = el.getAttribute('gs-id'); // read but never written out diff --git a/src/types.ts b/src/types.ts index 45e2cf42..61ae29a2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -256,8 +256,9 @@ export interface GridStackOptions { rtl?: boolean | 'auto'; /** set to true if all grid items (by default, but item can also override) height should be based on content size instead of WidgetItem.h to avoid v-scrollbars. - Note: this is still row based, not pixels, so it will use ceil(getBoundingClientRect().height / getCellHeight()) */ - sizeToContent?: boolean; + * Note: this is still row based, not pixels, so it will use ceil(getBoundingClientRect().height / getCellHeight()) + */ + sizeToContent?: boolean; /** * makes grid static (default?: false). If `true` widgets are not movable/resizable.