Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down