Skip to content

fix(datepicker): don't revalidate if new date object for same date is passed through input #20362

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

Merged
merged 1 commit into from
Sep 5, 2020

Conversation

crisbeto
Copy link
Member

If a function is used to provide a new date object for the min or max of a datepicker input, we currently trigger a revalidation on each change detection, because the input value is technically different. Historically this is something that we haven't fixed on our end, because it masks an anti-pattern on the user's end, however in this case it breaks in a non-obvious way and detecting it would be more code than just handling it.

These changes add checks in several places so that we don't trigger validators or extra change detections if a new date object for the same date is provided.

These changes also clean up the date range input which had both a stateChanges and _stateChanges streams which are required by two separate interfaces. Now there's a single stateChanges.

Fixes #19907.

@crisbeto crisbeto added P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release labels Aug 19, 2020
@crisbeto crisbeto requested a review from mmalerba as a code owner August 19, 2020 14:24
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 19, 2020
… passed through input

If a function is used to provide a new date object for the `min` or `max` of a datepicker input, we currently trigger a revalidation on each change detection, because the input value is technically different. Historically this is something that we haven't fixed on our end, because it masks an anti-pattern on the user's end, however in this case it breaks in a non-obvious way and detecting it would be more code than just handling it.

These changes add checks in several places so that we don't trigger validators or extra change detections if a new date object for the same date is provided.

These changes also clean up the date range input which had both a `stateChanges` and `_stateChanges` streams which are required by two separate interfaces. Now there's a single `stateChanges`.

Fixes angular#19907.
@crisbeto crisbeto force-pushed the 19907/datepicker-input-changes branch from 0c6f073 to ec8c387 Compare August 24, 2020 19:35
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Aug 24, 2020
@mmalerba mmalerba merged commit 6296da2 into angular:master Sep 5, 2020
mmalerba pushed a commit that referenced this pull request Sep 5, 2020
… passed through input (#20362)

If a function is used to provide a new date object for the `min` or `max` of a datepicker input, we currently trigger a revalidation on each change detection, because the input value is technically different. Historically this is something that we haven't fixed on our end, because it masks an anti-pattern on the user's end, however in this case it breaks in a non-obvious way and detecting it would be more code than just handling it.

These changes add checks in several places so that we don't trigger validators or extra change detections if a new date object for the same date is provided.

These changes also clean up the date range input which had both a `stateChanges` and `_stateChanges` streams which are required by two separate interfaces. Now there's a single `stateChanges`.

Fixes #19907.

(cherry picked from commit 6296da2)
@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 Oct 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(mat-date-range-picker): Unable to pick a date when using functions with [min],[max]
3 participants