Skip to content

Premium Analytics: fix date range calendar click selection#50179

Open
retrofox wants to merge 1 commit into
trunkfrom
fix/date-range-calendar-selection
Open

Premium Analytics: fix date range calendar click selection#50179
retrofox wants to merge 1 commit into
trunkfrom
fix/date-range-calendar-selection

Conversation

@retrofox

@retrofox retrofox commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #

Proposed changes

Fix the date range picker calendar so clicking two days selects the expected range.

With a complete range already selected, react-day-picker's default click behavior never restarts the range: it moves the endpoint nearest to the clicked day.

Clicking an intended start date inside the current range only moved the range's end, and clicking the intended end moved it again, so the two clicks could cancel out exactly and leave the original range untouched.

DateRangePopoverContent now implements the selection explicitly from the clicked day (triggerDate)

The first calendar click starts a new range, the second click completes it (endpoints are ordered, so clicking backward works too).

The in-progress half-open range is held locally in the popover ...

...and rendered by the calendar and the From/To inputs; consumers keep receiving complete ranges only, so the from && to guards in useReportDateFilters and ReportParamsField are unaffected.

Picking a preset or editing the From/To inputs clears any in-progress selection.

Does this pull request change what data or activity we track or use?

No.

Testing instructions

Storybook

  • cd projects/js-packages/storybook && pnpm run storybook:dev
  • Open Packages/Premium Analytics/UI/DateRangePopoverDefault and open the popover.
  • Click a day inside the current range (intended start), then a later day (intended end).
    • Before this PR: the first click only moved the range's end, so the final range kept the old start; if the second click matched the old end, the range ended up unchanged.
    • After: the first click starts a fresh range showing only that day, the second click completes it.
  • Click the two days in reverse order (end first, start second): same range is selected.
  • Click a day, then pick a preset from the sidebar: the preset wins and no half-selected state remains.
  • From/To inputs still work: focus From, pick a date, focus To, pick a date.

App

Before

Screen.Recording.2026-07-02.at.5.15.14.PM.mov

After

Screen.Recording.2026-07-02.at.5.15.32.PM.mov

In the app (jetpack build packages/premium-analytics, then wp-admin → ?page=jetpack-premium-analytics): repeat the same clicks in the dashboard header date picker, in a widget's edit-mode date field, and on the post-detail page. All three mount the same popover.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@jp-launch-control

jp-launch-control Bot commented Jul 2, 2026

Copy link
Copy Markdown

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report

@retrofox retrofox added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Jul 2, 2026
first click starts a new range; half-open draft stays local to the popover
@retrofox retrofox force-pushed the fix/date-range-calendar-selection branch from 0e9b8de to 59a1d6d Compare July 2, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant