Skip to content

Commit

Permalink
fix: ensure DOM alterations during initialization are always cleaned …
Browse files Browse the repository at this point in the history
…up when there are hidden parents and forceFitColumns=true
  • Loading branch information
jonathanjytang committed Nov 22, 2024
1 parent 6d5579c commit a9b52db
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/slick.grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
/** handles "display:none" on container or container parents, related to issue: https://github.com/6pac/SlickGrid/issues/568 */
cacheCssForHiddenInit() {
this._hiddenParents = Utils.parents(this._container, ':hidden') as HTMLElement[];
this.oldProps = [];
this._hiddenParents.forEach(el => {
const old: Partial<CSSStyleDeclaration> = {};
Object.keys(this.cssShow).forEach(name => {
Expand All @@ -1017,6 +1018,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
}
});
});
this._hiddenParents = [];
}
}

Expand Down Expand Up @@ -2745,9 +2747,14 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e

/** Proportionately resizes all columns to fill available horizontal space. This does not take the cell contents into consideration. */
autosizeColumns(autosizeMode?: string, isInit?: boolean) {
this.cacheCssForHiddenInit();
const checkHiddenParents= !(this._hiddenParents?.length);
if (checkHiddenParents) {
this.cacheCssForHiddenInit();
}
this.internalAutosizeColumns(autosizeMode, isInit);
this.restoreCssFromHiddenInit();
if (checkHiddenParents) {
this.restoreCssFromHiddenInit();
}
}

protected internalAutosizeColumns(autosizeMode?: string, isInit?: boolean) {
Expand Down

0 comments on commit a9b52db

Please sign in to comment.