Skip to content

Commit 1ae1481

Browse files
committed
tweak to resizeToContentCB - now takes useAttr
1 parent 43ec501 commit 1ae1481

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/gridstack.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,8 +1269,9 @@ export class GridStack {
12691269
* 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
12701270
*/
12711271
public resizeToContent(el: GridItemHTMLElement, useAttrSize = false) {
1272-
el?.classList.remove('size-to-content-max');
1273-
if (!el?.clientHeight) return; // 0 when hidden, skip
1272+
if (!el) return;
1273+
el.classList.remove('size-to-content-max');
1274+
if (!el.clientHeight) return; // 0 when hidden, skip
12741275
let n = el.gridstackNode;
12751276
if (!n) return;
12761277
const grid = n.grid;
@@ -1313,9 +1314,9 @@ export class GridStack {
13131314
}
13141315
}
13151316

1316-
/** call the user resize (so we can do extra work) else our build in version */
1317+
/** call the user resize (so they can do extra work) else our build in version */
13171318
protected resizeToContentCheck(el: GridItemHTMLElement, useAttr = false) {
1318-
if (GridStack.resizeToContentCB) GridStack.resizeToContentCB(el);
1319+
if (GridStack.resizeToContentCB) GridStack.resizeToContentCB(el, useAttr);
13191320
else this.resizeToContent(el, useAttr);
13201321
}
13211322

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export type AddRemoveFcn = (parent: HTMLElement, w: GridStackWidget, add: boolea
8686
/** optional function called during save() to let the caller add additional custom data to the GridStackWidget structure that will get returned */
8787
export type SaveFcn = (node: GridStackNode, w: GridStackWidget) => void;
8888

89-
export type ResizeToContentFcn = (els: GridItemHTMLElement) => void;
89+
export type ResizeToContentFcn = (el: GridItemHTMLElement, useAttr?: boolean) => void;
9090

9191
/**
9292
* Defines the options for a Grid

0 commit comments

Comments
 (0)