From 1ae148170ad28afd5c91bd1e372d7d934fba3005 Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Thu, 14 Sep 2023 08:35:27 -0700 Subject: [PATCH] tweak to resizeToContentCB - now takes useAttr --- src/gridstack.ts | 9 +++++---- src/types.ts | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gridstack.ts b/src/gridstack.ts index 62e127224..c3d1a10b3 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -1269,8 +1269,9 @@ export class GridStack { * useAttrSize set to true if GridStackNode.h should be used instead of actual container height when we don't need to wait for animation to finish to get actual DOM heights */ public resizeToContent(el: GridItemHTMLElement, useAttrSize = false) { - el?.classList.remove('size-to-content-max'); - if (!el?.clientHeight) return; // 0 when hidden, skip + if (!el) return; + el.classList.remove('size-to-content-max'); + if (!el.clientHeight) return; // 0 when hidden, skip let n = el.gridstackNode; if (!n) return; const grid = n.grid; @@ -1313,9 +1314,9 @@ export class GridStack { } } - /** call the user resize (so we can do extra work) else our build in version */ + /** call the user resize (so they can do extra work) else our build in version */ protected resizeToContentCheck(el: GridItemHTMLElement, useAttr = false) { - if (GridStack.resizeToContentCB) GridStack.resizeToContentCB(el); + if (GridStack.resizeToContentCB) GridStack.resizeToContentCB(el, useAttr); else this.resizeToContent(el, useAttr); } diff --git a/src/types.ts b/src/types.ts index 5b7b228d8..24940ae9b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -86,7 +86,7 @@ export type AddRemoveFcn = (parent: HTMLElement, w: GridStackWidget, add: boolea /** optional function called during save() to let the caller add additional custom data to the GridStackWidget structure that will get returned */ export type SaveFcn = (node: GridStackNode, w: GridStackWidget) => void; -export type ResizeToContentFcn = (els: GridItemHTMLElement) => void; +export type ResizeToContentFcn = (el: GridItemHTMLElement, useAttr?: boolean) => void; /** * Defines the options for a Grid