Skip to content

fix(date-range-picker): prevent mutating passed date range values - master#17231

Open
georgianastasov wants to merge 1 commit intomasterfrom
ganastasov/fix-17212-master
Open

fix(date-range-picker): prevent mutating passed date range values - master#17231
georgianastasov wants to merge 1 commit intomasterfrom
ganastasov/fix-17212-master

Conversation

@georgianastasov
Copy link
Copy Markdown
Contributor

Closes #17212

Description

Fixes an issue in IgxDateRangePicker where the date range passed through the value input 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 original Date instance, which reset the time portion to midnight.

This change ensures the component works with a cloned Date value instead of mutating the original one, preserving the passed time parts.

Motivation / Context

When IgxDateRangePicker is used together with IgxDateTimePicker, 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 Date objects and should behave consistently with string-based values.

Type of Change (check all that apply):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

Component(s) / Area(s) Affected:

  • Date Range Picker

How Has This Been Tested?

  • Verified that opening the date range picker no longer mutates the original Date objects passed through value.

  • 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:

  • Angular version: 22.0.x
  • Browser(s): Chrome
  • OS: Windows

Screenshots / Recordings

N/A

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a bug in IgxDateRangePickerComponent where consumer-provided Date instances (passed via the value input) could be mutated internally when initializing the calendar’s active date, resetting their time portion to midnight.

Changes:

  • Updated activeDate derivation to operate on a cloned Date instead of mutating the original range date.
  • Cleaned up unused test imports.
  • Added a unit test asserting that opening the picker does not mutate the passed-in range Date times.

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 Clones the range date before normalizing to midnight to prevent mutating the input Date.
projects/igniteui-angular/date-picker/src/date-range-picker/date-range-picker.component.spec.ts Adds a regression test for non-mutation of passed-in Date times and removes unused imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IgxDateRangePicker - Mutates the passed in date range

2 participants