Skip to content

IgxDateRangePicker - Mutates the passed in date range #17212

@remshams

Description

@remshams

Description

The date range passed in through the value property is mutated especially the time parts. In some cases it's reset to midnight.

It's possible to work around the issue by e.g. passing the string representation of the date (toISOString) into the component. That seems to avoid the problematic code section.

Framework

Angular

Angular Version

21.1.5

Ignite UI for Angular Version

21.0.12

Component / Area

Date Range Picker

Browser

Chrome

Operating System

macOS

Command Not Working

Steps to Reproduce

  1. Use the date range picker in combination with the IgxDateTimePicker for the input field.
  2. Change the time by manually editing the time in the input field (we are using the version of the date range picker where the "from" and "to" parts are two separate input fields).
  3. Open the date range picker again and select a new date range.

Actual Result

The time is reset to midnight.

Expected Result

The passed in date should not be mutated/the behavior should be similar as when passing a string as a value.

Reproduction URL

No response

Attachments

AI found the following flow leading to the mutation:

Flow

  1. Client passes value
    • date-range-picker.component.ts:552–556
  2. Picker stores it via updateValue
    • date-range-picker.component.ts:1015–1019
  3. Later, when the calendar is initialized/opened
    • _initializeCalendarContainer()
    • date-range-picker.component.ts:1317–1335
  4. That calls
    • _setCalendarActiveDate()
    • date-range-picker.component.ts:1395–1398
  5. _setCalendarActiveDate() uses this.activeDate
  6. activeDate getter does
    • date-range-picker.component.ts:476–479
    const dateValue = DateTimeUtil.isValidDate(this._firstDefinedInRange)
        ? new Date(this._firstDefinedInRange.setHours(0, 0, 0, 0))
        : null;

Metadata

Metadata

Labels

🐛 bugAny issue that describes a bug📅 date-range-picker✅ status: resolvedApplies to issues that have pending PRs resolving them, or PRs that have already merged.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions