Content-Length: 402521 | pFad | http://github.com/angular/components/pull/31076/commits/544f5c587f8ef1319a2d9327a6a0c91140ab259e

78 fix(cdk-experimental/scrolling): Fix ExpressionChangedAfterItWasCheckedError by atscott · Pull Request #31076 · angular/components · GitHub
Skip to content

fix(cdk-experimental/scrolling): Fix ExpressionChangedAfterItWasCheckedError #31076

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

Merged
merged 1 commit into from
May 21, 2025
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
fix(cdk-experimental/scrolling): Fix ExpressionChangedAfterItWasCheck…
…edError

This fixes an expressionchanged... error in the scrolling where template updates
were not accompanied by a change notification (`markforCheck`/signal
update, etc).
  • Loading branch information
atscott committed May 15, 2025
commit 544f5c587f8ef1319a2d9327a6a0c91140ab259e
4 changes: 2 additions & 2 deletions goldens/cdk/scrolling/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
setRenderedContentOffset(offset: number, to?: 'to-start' | 'to-end'): void;
setRenderedRange(range: ListRange): void;
setTotalContentSize(size: number): void;
_totalContentHeight: string;
_totalContentWidth: string;
_totalContentHeight: i0.WritableSignal<string>;
_totalContentWidth: i0.WritableSignal<string>;
// (undocumented)
static ɵcmp: i0.ɵɵComponentDeclaration<CdkVirtualScrollViewport, "cdk-virtual-scroll-viewport", never, { "orientation": { "alias": "orientation"; "required": false; }; "appendOnly": { "alias": "appendOnly"; "required": false; }; }, { "scrolledIndexChange": "scrolledIndexChange"; }, never, ["*"], true, never>;
// (undocumented)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {CdkVirtualScrollViewport, ScrollingModule} from '@angular/cdk/scrolling';
import {
Component,
Input,
provideCheckNoChangesConfig,
ViewChild,
ViewEncapsulation,
} from '@angular/core';
import {Component, Input, ViewChild, ViewEncapsulation} from '@angular/core';
import {ComponentFixture, TestBed, fakeAsync, flush, waitForAsync} from '@angular/core/testing';
import {ScrollingModule as ExperimentalScrollingModule} from './scrolling-module';

Expand All @@ -17,7 +11,6 @@ describe('CdkVirtualScrollViewport', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [ScrollingModule, ExperimentalScrollingModule, AutoSizeVirtualScroll],
});
}));
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/scrolling/virtual-scroll-viewport.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
so that the scrollbar captures the size of the entire data set.
-->
<div class="cdk-virtual-scroll-spacer"
[style.width]="_totalContentWidth" [style.height]="_totalContentHeight"></div>
[style.width]="_totalContentWidth()" [style.height]="_totalContentHeight()"></div>
15 changes: 9 additions & 6 deletions src/cdk/scrolling/virtual-scroll-viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
OnInit,
Optional,
Output,
signal,
ViewChild,
ViewEncapsulation,
} from '@angular/core';
Expand Down Expand Up @@ -137,10 +138,10 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
private _totalContentSize = 0;

/** A string representing the `style.width` property value to be used for the spacer element. */
_totalContentWidth = '';
_totalContentWidth = signal('');

/** A string representing the `style.height` property value to be used for the spacer element. */
_totalContentHeight = '';
_totalContentHeight = signal('');

/**
* The CSS transform applied to the rendered subset of items so that they appear within the bounds
Expand Down Expand Up @@ -533,9 +534,11 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On

/** Calculates the `style.width` and `style.height` for the spacer element. */
private _calculateSpacerSize() {
this._totalContentHeight =
this.orientation === 'horizontal' ? '' : `${this._totalContentSize}px`;
this._totalContentWidth =
this.orientation === 'horizontal' ? `${this._totalContentSize}px` : '';
this._totalContentHeight.set(
this.orientation === 'horizontal' ? '' : `${this._totalContentSize}px`,
);
this._totalContentWidth.set(
this.orientation === 'horizontal' ? `${this._totalContentSize}px` : '',
);
}
}
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/angular/components/pull/31076/commits/544f5c587f8ef1319a2d9327a6a0c91140ab259e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy