components
components copied to clipboard
bug(DatePicker): Cannot pick date when setting [max] input to a getter/method that returns new Date()
Reproduction
https://stackblitz.com/angular/jaapndnmprrv?file=src%2Fapp%2Fdatepicker-min-max-example.ts
Steps to reproduce:
- Convert the maxDate property to a maxDate getter.
export class DatepickerMinMaxExample {
minDate: Date;
get maxDate(): Date {
return new Date();
}
constructor() {
const currentYear = new Date().getFullYear();
this.minDate = new Date(currentYear - 20, 0, 1);
}
}
- Open the calendar of the datepicker and try picking a day.
Expected Behavior
The date is successfully picked and the calendar is closed.
Actual Behavior
Nothing happens and the calendar remains opened.
NOTE: The issue is not reproduced in the Angular 8 version of the stackblitz example.
Environment
- Angular: 10.0.0
- CDK/Material: 10.0.0
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): All
Duplicate of https://github.com/angular/components/issues/19907.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.