Skip to content

Premium Analytics: build the chart interval menu on the design system Menu - #51708

Closed
retrofox wants to merge 3 commits into
renovate/bundled-@wordpress-monorepofrom
update/interval-menu-wordpress-ui
Closed

retrofox wants to merge 3 commits into
renovate/bundled-@wordpress-monorepofrom
update/interval-menu-wordpress-ui

Conversation

@retrofox

Copy link
Copy Markdown
Contributor

Fixes WOOA7S-2026

Stacked on #51701: the base branch is renovate/bundled-@wordpress-monorepo, since Menu needs @wordpress/ui 0.21.0. Once that lands, this rebases onto trunk and the base moves with it; the diff here is the one commit on top.

Proposed changes

WOOA7S-2026 asks for the chart intervals to sit behind a button and to default automatically. Both are already on trunk: DateIntervalDropdown is a glyph-only trigger after the comparison control (WOOA7S-1813, WOOA7S-1929), and the hook resolves the range default whenever the URL carries no interval or a range change stops allowing the pick (getAllowedIntervalsForPreset, resolveIntervalForRange, buildRangePatch). Which buckets each range and widget offer is WOOA7S-1928 and WOOA7S-2005.

What this PR changes is the menu itself, to match the prototype frame on the issue and to take the first @wordpress/ui Menu in the package:

  • DateIntervalDropdown renders Menu.Root, Menu.Trigger with a design system IconButton (outline, neutral, the same 40px box and stroke the shared mixin restated by hand), and Menu.Popup with a Menu.RadioGroup. Menu reaches it through @jetpack-premium-analytics/externals, like the rest of @wordpress/ui.
  • The menu is headed Chart intervals and lists Hours, Days, Weeks, Months, Years, the copy the prototype shows, instead of By days and so on.
  • The radio group stays controlled with null when the active bucket is not among the options, so the transient state the report params coerce away checks nothing rather than the group keeping its own selection.
  • The icon-toggle mixin and the dropdown's stylesheet go: the design system button already is that box. The comparison control keeps the toggle mixin until WOOA7S-2028 reworks it.

Gutenberg lists Menu as use with caution while its API settles (WordPress/gutenberg#76135).

Two things a single prototype frame cannot settle, and that this PR leaves as they are: the recommended default is the finest bucket the range allows (days for Last 30 days, where the frame shows weeks checked), and a manual pick sticks across range changes for as long as the new range allows it.

Screenshots

Before After
before after

Related product discussion/links

  • Linear: WOOA7S-2026, in the "Jetpack Stats v2: Revised date range picker" project.
  • Eder's 26 August recap on the Unified Analytics P2, "Chart intervals hidden under a button and working automatically".
  • Update Bundled @wordpress/* monorepo #51701, the @wordpress/ui 0.21.0 bump this builds on.

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

No.

Testing instructions

  • Build the package: jetpack build --deps packages/premium-analytics.
  • Open Stats and, on the Traffic tab, click the chart glyph at the end of the date controls. The menu is headed Chart intervals, lists Days and Weeks for Last 30 days with the active one marked, and picking Weeks re-buckets the charts and closes the menu. The trigger reads as a sibling of Compare beside it: same height, same stroke, same radius.
  • Switch to Last 7 days: the menu lists Days alone, still opens, still marked. Switch to Last 24 hours: Hours alone.
  • Keyboard: Tab to the glyph, Enter opens the menu with the active bucket focused, arrows move, Enter picks, Escape closes and returns focus to the glyph.
  • Insights tab (year surface): the same menu next to the year picker, listing Months and Years for All time.
  • Ads tab: the WordAds card hosts the same control; its menu never lists Hours.
  • Storybook: Packages/Premium Analytics/UI/DateIntervalDropdown and the SectionHeader stories render the new menu.

@retrofox
retrofox requested a review from a team as a code owner August 28, 2026 12:36
@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. [Status] Blocked / Hold labels Aug 28, 2026
@retrofox retrofox self-assigned this Aug 28, 2026
@github-actions

github-actions Bot commented Aug 28, 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/interval-menu-wordpress-ui branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/interval-menu-wordpress-ui
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/interval-menu-wordpress-ui

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

@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 Aug 28, 2026
@github-actions

github-actions Bot commented Aug 28, 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.

@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

No summary data is available for parent commit d392e61, so cannot calculate coverage changes. 😴

If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, this should be updated once coverage for d392e61 is available.

Full summary · PHP report · JS report

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! @retrofox Overall, looks good.

I noticed picking a bucket doesn't close the menu. Menu.RadioItem defaults closeOnClick to false, and adding it fixed this for me.

Screen.Recording.2026-08-31.at.11.00.25.AM.mov

Also, regarding building this on Menu. The DS guidelines say to use SelectControl when picking a value is the whole point of the control. Should we confirm with DS?

Using radio items to recreate a Select. Use Menu.RadioItem only when the state belongs inside a broader command menu. -
https://wordpress.github.io/gutenberg/?path=/docs/design-system-components-menu-usage-guidelines--docs#common-mistakes

with the section header subtitle gone, nothing else read it back
Base UI keeps radio items open, for settings toggled in bunches
@retrofox

Copy link
Copy Markdown
Contributor Author

Thanks for working on this! @retrofox Overall, looks good.
👍

I noticed picking a bucket doesn't close the menu. Menu.RadioItem defaults closeOnClick to false, and adding it fixed this for me.

Using radio items to recreate a Select. Use Menu.RadioItem only when the state belongs inside a broader command menu. -
https://wordpress.github.io/gutenberg/?path=/docs/design-system-components-menu-usage-guidelines--docs#common-mistakes

I don't see a straightforward escape from this trap. To me, using a Select component for this is a mistake

First, it's a Form component that behaves like a Menu.

Second, a UI limitation: it isn't possible to define the glyph. The Select component shows the selected value, which makes total sense when it's part of a Form.

Alternatives:

image

We can use the simplest menu items (Rename..., Archive, Save), but they don't highlight the selected value, which makes sense. Its nature is a Menu; it isn't a select.

Compared with macOS native Menu:

image

So, for now, we should simply close this PR. The Menu doesn't seem to cover our needs. I prefer to keep using what we have today:

image

A note about the macOS menu:

image

When I select the radio item using this menu, it closes right after I click it.

@retrofox retrofox closed this Aug 31, 2026
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Aug 31, 2026
@retrofox
retrofox deleted the update/interval-menu-wordpress-ui branch August 31, 2026 11:19
@retrofox

Copy link
Copy Markdown
Contributor Author

@chihsuan I suggest keep using the DropdownMenu for now #51770

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] Blocked / Hold

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants