fix(date-range-picker): prevent mutating passed date range values - 20.1.x#17233
Open
georgianastasov wants to merge 1 commit into20.1.xfrom
Open
fix(date-range-picker): prevent mutating passed date range values - 20.1.x#17233georgianastasov wants to merge 1 commit into20.1.xfrom
georgianastasov wants to merge 1 commit into20.1.xfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes IgxDateRangePicker mutating consumer-provided Date instances (time portion) when initializing the calendar active date.
Changes:
- Update
activeDategetter to normalize to midnight using a clonedDateinstead of callingsetHours(...)on the original instance. - Add a unit test verifying that opening the picker does not mutate the time parts 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/src/lib/date-range-picker/date-range-picker.component.ts | Prevents mutation of the underlying Date used to compute activeDate by cloning before normalizing to midnight. |
| projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts | Adds coverage ensuring the picker open flow doesn’t mutate passed-in date times. |
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)