fix(date-range-picker): prevent mutating passed date range values - 21.2.x#17232
Open
georgianastasov wants to merge 1 commit into21.2.xfrom
Open
fix(date-range-picker): prevent mutating passed date range values - 21.2.x#17232georgianastasov wants to merge 1 commit into21.2.xfrom
georgianastasov wants to merge 1 commit into21.2.xfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an IgxDateRangePicker bug where opening the picker could mutate consumer-provided Date instances (resetting their time to midnight) by ensuring the component operates on a cloned Date when normalizing the active date.
Changes:
- Avoid mutating
_firstDefinedInRangeby cloning before callingsetHours(0, 0, 0, 0)in theactiveDategetter. - Clean up unused test imports and add a unit test asserting that opening the picker does not mutate the time portion of the passed-in
DateRangevalue.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
projects/igniteui-angular/date-picker/src/date-range-picker/date-range-picker.component.ts |
Prevents activeDate normalization from mutating the original Date instance. |
projects/igniteui-angular/date-picker/src/date-range-picker/date-range-picker.component.spec.ts |
Adds coverage to ensure passed-in Date times aren’t mutated on open; removes unused imports. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #17212
Description
Fixes an issue in
IgxDateRangePickerwhere the date range passed through thevalueinput could be mutated internally.Previously, when the picker was reopened and the calendar active date was initialized, the component could call
setHours(0, 0, 0, 0)on the originalDateinstance, which reset the time portion to midnight.This change ensures the component works with a cloned
Datevalue instead of mutating the original one, preserving the passed time parts.Motivation / Context
When
IgxDateRangePickeris used together withIgxDateTimePicker, manually editing the time and then reopening/selecting a new date range could reset the time to midnight.The component should not mutate consumer-provided
Dateobjects and should behave consistently with string-based values.Type of Change (check all that apply):
Component(s) / Area(s) Affected:
How Has This Been Tested?
Verified that opening the date range picker no longer mutates the original
Dateobjects passed throughvalue.Verified that manually entered time values are preserved after reopening the picker and selecting a new range.
Added/updated unit tests covering the non-mutation behavior and time preservation.
Unit tests
Manual testing
Automated e2e tests
Test Configuration:
Screenshots / Recordings
N/A
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)