angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.34k stars 6.74k forks source link

bug(DatePicker): Mat Datepicker is firing matDatepickerFilter with a null value in 12.2.13 but in 9.2.0 it doesn't. #24728

Open MathewBerg opened 2 years ago

MathewBerg commented 2 years ago

Is this a regression?

The previous version in which this bug was not present was

9.2.0

Description

Adding a matDatepickerFilter onto a datepicker in 12.2.13 has the filter execute immediately along with a null value. I have not done a deep dive to see which version introduced this, we went from 9.x to 12.x and only noticed it when our testers raised a different issue.

Reproduction

  1. Create a mat datepicker component
  2. Wire up a simple matDatepickerFilter with a console.log

12.2.13 with the extra log: https://stackblitz.com/edit/angular-11-material-reactive-starter-mfw6fz?file=src%2Fapp%2Fapp.component.ts

9.2.0 without the extra log: https://stackblitz.com/edit/angular-9-expression-changed-issue-8rykpo?file=src%2Fapp%2Fapp.component.ts

Expected Behavior

It shouldn't be firing since the datepicker has not been opened.

Actual Behavior

It fires, and with a value of null.

Environment

volvachev commented 2 years ago

I'm not sure if this is a bug. It happened after fixed issue (#20967).

MathewBerg commented 2 years ago

@volvachev the bug lies in that I don't believe the filter should be executing if the datepicker is not opened since there should be nothing to filter out.

It's not the end of the world by any means, we can have a check where we used to not need one now.