Skip to content

Premium Analytics: name the selected period on the date range control - #51817

Merged
retrofox merged 3 commits into
trunkfrom
update/date-range-natural-language
Sep 1, 2026
Merged

retrofox merged 3 commits into
trunkfrom
update/date-range-natural-language

Conversation

@retrofox

@retrofox retrofox commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

  • The custom date range trigger names the period its range covers, where the range is one: a whole calendar month reads July 2026, a whole calendar year reads 2026. Every other range keeps the shortest form it already had.
  • The exact dates move to the trigger's tooltip. #51707 removed the section header subtitle, so this is now the only place they are readable without opening the calendar.
  • New formatter formatDateRangeNatural in packages/formatters. Its two collapses format a single date rather than a range, so elideRange and its CLDR probes are not involved; everything else falls through to formatDateRangeMinimal unchanged.
  • New named format monthYear, derived from the site's own date_format by a withoutDay transform mirroring the existing withoutYear: F j, Y → F Y, Y-m-d → Y-m, j \d\e F \d\e Y → F \d\e Y. The weekday goes with the day, and an ordinal suffix (jS) goes with the day it trails.

Both collapses keep the year, including in the current one. This label is the only thing naming the period on the control, so a bare March would not say which March.

Both call sites of getCustomTriggerLabel move together, since the panel's measuring probe has to measure the string the trigger is actually showing.

Two decisions worth flagging:

  • The tooltip appears only while the trigger holds a range of its own, staged or applied. While a preset drives the range the trigger reads Custom, and a tooltip there would put the preset's range on a control that is not showing it (WOOA7S-1936).
  • No aria-label. The button already has visible text, unlike the interval glyph, so an aria-label carrying the exact range would replace the accessible name and break its correspondence with the visible label. Tooltip supplies aria-describedby, which is the right role for a complement.

A range covering two whole months (Mar 1 – Apr 30) does not collapse: it names no single period, and the spec asks for the shortest form rather than an invented one.

Related product discussion/links

  • Linear: WOOA7S-2024. The collapsing rules were confirmed on the issue: the full-month example's March 30 was a typo, the year stays in the current year too, and only whole months and whole years collapse.
  • Spec: Eder's 26 August recap, "Date selection" section.

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

No.

Testing instructions

  • Build the dashboard: jetpack build --deps packages/premium-analytics.

  • Open any analytics page.
    The steps below assume the site's date format (Settings → General → Date format) is the English default, F j, Y; the last step covers a different one.

  • Open the custom range picker, select the first and last day of a past month, and Apply. The trigger reads the month and its year, for example July 2026.

image
  • Hover or focus the trigger. Its tooltip spells the exact dates out: July 1 – 31, 2026.
image
  • Select January 1 to December 31 of a year. The trigger reads just the year.
image image
  • Select the first to the second-to-last day of a month. The trigger falls back to the range, as before.
  • Pick a rolling preset such as Last 30 days. The trigger goes back to reading Custom, with no tooltip.
  • With the trigger showing a period, press Tab into the date controls toolbar and then End. Focus lands on the trigger, and the arrow keys still move along the row.
  • Change Settings → General → Date format to d/m/Y and repeat the first step. The month reads 07/2026, taken from the site's own format rather than an English one.

Storybook: Packages/Premium Analytics/UI/DateRangePopover → CustomWholeMonth.

a whole calendar month or year reads as itself; anything else stays minimal
the exact dates move to its tooltip; the header subtitle no longer carries them
@retrofox
retrofox requested a review from a team as a code owner September 1, 2026 09:17
@retrofox retrofox added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. labels Sep 1, 2026
@retrofox retrofox self-assigned this Sep 1, 2026
@github-actions github-actions Bot added [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics labels Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 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!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: September 7, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Premium Analytics plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the update/date-range-natural-language branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/date-range-natural-language
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/date-range-natural-language

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 4 files.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/packages/formatters/src/date/format-date-range.ts 36/36 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/packages/formatters/src/date/format-date.ts 55/55 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/packages/formatters/src/date/php-format.ts 71/71 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/packages/ui/src/date-range-popover/date-range-filter.tsx 37/43 (86.05%) 0.68% 0 💚

Full summary · PHP report · JS report

@retrofox
retrofox merged commit 60219cf into trunk Sep 1, 2026
87 of 88 checks passed
@retrofox
retrofox deleted the update/date-range-natural-language branch September 1, 2026 11:33
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Review This PR is ready for review. labels Sep 1, 2026
@retrofox
retrofox restored the update/date-range-natural-language branch September 1, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Status] UI Changes Add this to PRs that change the UI so documentation can be updated.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant