Skip to content

feature/date-reverse-ordered-range#8130

Open
deb2000-sudo wants to merge 2 commits into
palantir:developfrom
deb2000-sudo:debashis/date-reverse-ordered-range
Open

feature/date-reverse-ordered-range#8130
deb2000-sudo wants to merge 2 commits into
palantir:developfrom
deb2000-sudo:debashis/date-reverse-ordered-range

Conversation

@deb2000-sudo
Copy link
Copy Markdown

@deb2000-sudo deb2000-sudo commented May 22, 2026

Fixes #8122

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

Here I have changed in dateRangePicker.tsx there is a function called handleTimeChange I have modified the code on that

Reviewers should focus on:

private handleTimeChange = (newTime: Date, dateIndex: number) => {
this.props.timePickerProps?.onChange?.(newTime);

    const { value, time } = this.state;
    const newValue = DateUtils.getDateTime(
        value[dateIndex] != null ? DateUtils.clone(value[dateIndex]!) : this.getDefaultDate(dateIndex),
        newTime,
    );
    const newDateRange: DateRange = [value[0], value[1]];
    newDateRange[dateIndex] = newValue;
    const newTimeRange: DateRange = [time[0], time[1]];
    newTimeRange[dateIndex] = newTime;

    if (newDateRange[0] != null && newDateRange[1] != null && newDateRange[0] > newDateRange[1]) {
    const temp = newDateRange[0];
    newDateRange[0] = newDateRange[1];
    newDateRange[1] = temp;

    const tempTime = newTimeRange[0];
    newTimeRange[0] = newTimeRange[1];
    newTimeRange[1] = tempTime;
}

    this.props.onChange?.(newDateRange);
    this.setState({ time: newTimeRange, value: newDateRange });
};

Screenshot

closes #8122

Copilot AI review requested due to automatic review settings May 22, 2026 08:34
@palantirtech
Copy link
Copy Markdown
Member

Thanks for your interest in palantir/blueprint, @deb2000-sudo! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

@changelog-app
Copy link
Copy Markdown

changelog-app Bot commented May 22, 2026

Generate changelog in packages/datetime/changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

feature/date-reverse-ordered-range

Check the box to generate changelog(s)

  • Generate changelog entry

Copy link
Copy Markdown

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

Note

Copilot was unable to run its full agentic suite in this review.

Updates the DateRangePicker time-change behavior to automatically normalize (swap) the selected range when the start date-time becomes later than the end date-time.

Changes:

  • Added logic in handleTimeChange to swap newDateRange entries when they become reverse-ordered.
  • Kept newTimeRange in sync by swapping the corresponding time entries when the date range is swapped.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +271 to +278
const temp = newDateRange[0];
newDateRange[0] = newDateRange[1];
newDateRange[1] = temp;

const tempTime = newTimeRange[0];
newTimeRange[0] = newTimeRange[1];
newTimeRange[1] = tempTime;
}
Comment thread packages/datetime/src/components/date-range-picker/dateRangePicker.tsx Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DateRangePicker: time-picker changes can emit reverse-ordered ranges

3 participants