angular/components

bug(CdkOption): CdkListbox/CdkOption - expression changed after checked error | experimental zoneless change detection

Closed this issue · 0 comments

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

I am preparing for zoneless change detection and configured my app with those providers:

provideExperimentalZonelessChangeDetection(),
provideExperimentalCheckNoChangesForDebug({
    interval: 10000,
    exhaustive: true,
    // useNgZoneOnStable: true,
}),

An expression changed after it has been checked error is thron w/ CdkOption_HostBindings (listbox.mjs:165:59) in the stack trace.

Reproduction

StackBlitz reproduction

Run in StackBlitz and open the developer console.

  • As long as the user does not interact w/ any button, the expression has changed after it has been checked error is thrown in each interval.
  • As soon as any button is pressed, the error is not thrown any more.

Expected Behavior

The error not being thrown - given that I did not make a mistake while providing the initial value.

Actual Behavior

ERROR RuntimeError: NG0100: ExpressionChangedAfterItHasBeenCheckedError:
Expression has changed after it was checked. Previous value for 'attr.tabindex': '-1'. Current value: '0'.
Expression location: _SomeOnPushComponent component. Find more at https://angular.dev/errors/NG0100
    at throwErrorIfNoChangesMode (core.mjs:10493:9)
    at bindingUpdated (core.mjs:18604:9)
    at ɵɵattribute (core.mjs:20540:7)
    at CdkOption_HostBindings (listbox.mjs:165:59)
    at processHostBindingOpCodes (core.mjs:11662:9)
    at refreshView (core.mjs:13392:5)
    at detectChangesInView (core.mjs:13552:5)
    at detectChangesInViewIfAttached (core.mjs:13514:3)
    at detectChangesInEmbeddedViews (core.mjs:13474:7)
    at refreshView (core.mjs:13371:5)

Environment

  • Angular: 18.2.9
  • CDK/Material: 18.2.10
  • Browser(s): Edge 128.0.2739.54
  • Operating System: Windows 11
  • Node: 22.10.0
  • OS: win32-x64
  • Native Target: x86_64-windows
  • yarn: 4.5.1