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(igxGrid): Add a more targeted fix to skip only the first initial … #14003

Merged
merged 3 commits into from
Jun 12, 2024
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
16 changes: 14 additions & 2 deletions projects/igniteui-angular/src/lib/grids/grid-base.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3074,6 +3074,8 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
protected _defaultExpandState = false;
protected _headerFeaturesWidth = NaN;
protected _init = true;
protected _firstAutoResize = true;
protected _autoSizeColumnsNotify = new Subject<boolean>();
protected _cdrRequestRepaint = false;
protected _userOutletDirective: IgxOverlayOutletDirective;
protected _transactions: TransactionService<Transaction, State>;
Expand Down Expand Up @@ -3674,6 +3676,16 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
}
this.notifyChanges(true);
});

// notifier for column autosize requests
this._autoSizeColumnsNotify.pipe(
throttleTime(0, animationFrameScheduler, { leading: false, trailing: true }),
destructor
)
.subscribe(() => {
this.autoSizeColumnsInView();
this._firstAutoResize = false;
});
}

/**
Expand Down Expand Up @@ -6757,7 +6769,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
if (this.hasColumnsToAutosize) {
this.cdr.detectChanges();
this.zone.onStable.pipe(first()).subscribe(() => {
this.autoSizeColumnsInView();
this._autoSizeColumnsNotify.next();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just this.zone.onStable.pipe(first()).subscribe(this._autoSizeColumnsNotify); should do too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem to trigger correctly like that:
image

});
}
}
Expand Down Expand Up @@ -7231,7 +7243,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
emptyCellWithPaddingOnly = parseFloat(cellStyle.paddingLeft) + parseFloat(cellStyle.paddingRight);
}

if (max === 0 || max <= emptyCellWithPaddingOnly) {
if (max === 0 || (max <= emptyCellWithPaddingOnly && this._firstAutoResize)) {
// cells not in DOM yet or content not fully initialized.
continue;
}
Expand Down
Loading