Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure DOM alterations during initialization are always cleaned up when there are hidden parents and forceFitColumns=true #1085

Merged
Merged
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
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