-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Description
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
18.2
Description
We are using the a combination of the viewChildren signal, the input signal and an effect to dynamically update the dates that can be selected by the user and if an css class should be added to a date.
In the previouse version this worked without problems but after an update this stopped and instead throws an error. Now an "Cannot read properties of undefined (reading '_init')" is thrown. The reason is that the effect is triggery by the viewChildren signal before the calendar ist fully initialized.
When calling "updateTodaysDate()" the calendar trys to resolve with view component is used by calling the "_getCurrentViewComponent()" method which returns undefined as non of this.monthView, this.yearView, or this.multiYearView variables are set.
We currently use a "is first time check" workaround to make sure that the calendar component is fully initialized before running our code.
Reproduction
StackBlitz link: https://stackblitz.com/edit/components-issue-starter-m4uybm72
Steps to reproduce:
- open the StackBlitz link
- open the browser dev console (F12)
- wait for the application to load
Expected Behavior
The component should be fully initialized and no Error should be thrown.
Actual Behavior
the component throws an "Cannot read properties of undefined " error
ERROR TypeError: Cannot read properties of undefined (reading '_init')
at _MatCalendar.updateTodaysDate (@angular_material_datepicker.js?v=50545779:3187:36)
at Object.fn (main.ts:20:11)
at Object.run (chunk-VW6ZTUEV.js?v=3212bb7c:29150:12)
Environment
- Angular: 19.2
- CDK/Material: 19.2
- Browser(s): all
- Operating System (e.g. Windows, macOS, Ubuntu): all