Skip to content

fix(date-range-picker): prevent mutating passed date range values - 21.2.x#17232

Open
georgianastasov wants to merge 1 commit into21.2.xfrom
ganastasov/fix-17212-21.2.x
Open

fix(date-range-picker): prevent mutating passed date range values - 21.2.x#17232
georgianastasov wants to merge 1 commit into21.2.xfrom
ganastasov/fix-17212-21.2.x

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: 21.2.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 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 _firstDefinedInRange by cloning before calling setHours(0, 0, 0, 0) in the activeDate getter.
  • 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 DateRange value.

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.

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.

2 participants