components icon indicating copy to clipboard operation
components copied to clipboard

bug(DatePicker): Cannot pick date when setting [max] input to a getter/method that returns new Date()

Open tachojelev opened this issue 6 years ago • 2 comments

Reproduction

https://stackblitz.com/angular/jaapndnmprrv?file=src%2Fapp%2Fdatepicker-min-max-example.ts

Steps to reproduce:

  1. 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);
  }
}
  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

tachojelev avatar Aug 24 '20 08:08 tachojelev

Duplicate of https://github.com/angular/components/issues/19907.

crisbeto avatar Aug 24 '20 08:08 crisbeto

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.