Skip to content
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

bug(material/datepicker): unable to select date on inline-calendar when passing a new Date() to the [minDate] Input #24435

Closed
zarend opened this issue Feb 16, 2022 · 1 comment · Fixed by #24434

Comments

@zarend
Copy link
Contributor

zarend commented Feb 16, 2022

Is this a regression?

#24384 introduces this bug

Description

When passing a new Date() to the [minDate] Input on mat calendar, selectedDateChange is not emitted when clicking on a date with the mouse.

Reproduction

Steps to reproduce:

  1. Open the Stackblitz example
  2. Click on any date on the calendar

Expected Behavior

Should display the selected date below the calendar and log the current date

Actual Behavior

Nothing happens, the selected date does not change, and nothing is logged to the console.

Environment

Macos 12.2.1 (21D62), Chrome 98.0.4758.102

Additional notes from bug reported

I would not recommend passing a new Date() every time to the minDate or maxDate inputs, even if it didn't cause this bug. I'll write up this bug for it anyways as something to consider.

@zarend zarend added the needs triage This issue needs to be triaged by the team label Feb 16, 2022
@zarend zarend changed the title bug(COMPONENT): TITLE bug(material/datepicker): unable to select date on inline-calendar when passing a new Date() to the [minDate] Input Feb 16, 2022
@zarend zarend added area: material/datepicker and removed needs triage This issue needs to be triaged by the team labels Feb 16, 2022
zarend added a commit to zarend/components that referenced this issue Feb 16, 2022
…e or maxDate is at a different time on the same day

Avoid re-rendering <mat-calendar/>  when it receives a new value for
either the [minDate] or [maxDate] Input, and the value is at a different time on the same day.

Make two code changes to `MatCalendar` to accomplish this behavior change.
 - Normalize `_minDate` and `_maxDate` to midnight of the given day
 - Add check in `ngOnChanges` to re-render only if the current minDate
   is not equal to the previous minDate.

Fixes angular#24435
zarend added a commit to zarend/components that referenced this issue Mar 22, 2022
…different time on the same day

Avoid re-rendering <mat-calendar/> when the [minDate] or [maxDate]
Input change to a different time on the same day.

In `ngOnChanges`, do not call `init` if the previous and current value for
minDate/maxDate are on the same day. This makes angular#24384 a non-breaking
code change.

Fixes angular#24435
zarend added a commit to zarend/components that referenced this issue Mar 22, 2022
…different time on the same day

Avoid re-rendering <mat-calendar/> when the [minDate] or [maxDate]
Input change to a different time on the same day.

In `ngOnChanges`, do not call `init` if the previous and current value for
minDate/maxDate are on the same day. This makes angular#24384 a non-breaking
code change.

Fixes angular#24435
zarend added a commit to zarend/components that referenced this issue Mar 22, 2022
…different time on the same day

Avoid re-rendering <mat-calendar/> when the [minDate] or [maxDate]
Input change to a different time on the same day.

In `ngOnChanges`, do not call `init` if the previous and current value for
minDate/maxDate are on the same day. This makes angular#24384 a non-breaking
code change.

Fixes angular#24435
zarend added a commit to zarend/components that referenced this issue Mar 22, 2022
…different time on the same day

Avoid re-rendering <mat-calendar/> when the [minDate] or [maxDate]
Input change to a different time on the same day.

In `ngOnChanges`, do not call `init` if the previous and current value for
minDate/maxDate are on the same day. This makes angular#24384 a non-breaking
code change.

Fixes angular#24435
zarend added a commit to zarend/components that referenced this issue Mar 28, 2022
…different time on the same day

Avoid re-rendering <mat-calendar/> when the [minDate] or [maxDate]
Input change to a different time on the same day.

In `ngOnChanges`, do not call `init` if the previous and current value for
minDate/maxDate are on the same day. This makes angular#24384 a non-breaking
code change.

Fixes angular#24435
zarend added a commit to zarend/components that referenced this issue Mar 28, 2022
…different time on the same day

Avoid re-rendering <mat-calendar/> when the [minDate] or [maxDate]
Input change to a different time on the same day.

In `ngOnChanges`, do not call `init` if the previous and current value for
minDate/maxDate are on the same day. This makes angular#24384 a non-breaking
code change.

Fixes angular#24435
andrewseguin pushed a commit that referenced this issue Mar 31, 2022
…different time on the same day (#24434)

Avoid re-rendering <mat-calendar/> when the [minDate] or [maxDate]
Input change to a different time on the same day.

In `ngOnChanges`, do not call `init` if the previous and current value for
minDate/maxDate are on the same day. This makes #24384 a non-breaking
code change.

Fixes #24435
andrewseguin pushed a commit that referenced this issue Mar 31, 2022
…different time on the same day (#24434)

Avoid re-rendering <mat-calendar/> when the [minDate] or [maxDate]
Input change to a different time on the same day.

In `ngOnChanges`, do not call `init` if the previous and current value for
minDate/maxDate are on the same day. This makes #24384 a non-breaking
code change.

Fixes #24435

(cherry picked from commit 6f9743c)
forsti0506 pushed a commit to forsti0506/components that referenced this issue Apr 3, 2022
…different time on the same day (angular#24434)

Avoid re-rendering <mat-calendar/> when the [minDate] or [maxDate]
Input change to a different time on the same day.

In `ngOnChanges`, do not call `init` if the previous and current value for
minDate/maxDate are on the same day. This makes angular#24384 a non-breaking
code change.

Fixes angular#24435
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
1 participant