Skip to content

Premium Analytics: resolve toggle group option icons by reference - #53771

Open
retrofox wants to merge 5 commits into
trunkfrom
update/toggle-group-icon-references
Open

retrofox wants to merge 5 commits into
trunkfrom
update/toggle-group-icon-references

Conversation

@retrofox

@retrofox retrofox commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Part of WOOA7S-2290

Proposed changes

jpa/toggle-group accepts the icon of an option as a jpa/<name> reference

It happens next to a React element and resolves it through the dashboard's icon collection (lookupWidgetIcon() from @jetpack-premium-analytics/icons).

If the collection lacks a reference, it drops that icon and the row falls back to text segments instead of showing a blank one.

WIDGET_API_VERSION moves to 1.15.0

A consumer may rely on the reference form. This is the client-side half of WOOA7S-2290.

With it, the elements of a jpa/toggle-group attribute are serializable, which is what moving the attribute to widget.json needs. #53778, which builds on this PR, moves the chart type attribute of the fifteen chart widgets there; the widgets keep their React element icons here.

Related product discussion/links

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

No.

Testing instructions

Build the package with its dependencies

jetpack build --deps packages/premium-analytics

Open the Premium Analytics dashboard

Nothing changes: every chart widget still hands the control React elements, so the line/bar toggle in their headers draws as before.

Storybook: Packages/Premium Analytics/Fields/ToggleGroupField renders the Default and WithVisibleLabel stories as icon segments from jpa/chart-line and jpa/chart-bar references.

Running test

pnpm run test in projects/packages/premium-analytics: the toggle group field suite covers the reference form and the text fallback.

jpa/toggle-group takes jpa/<name> icons; drops the chart-line copies
@github-actions

github-actions Bot commented Oct 19, 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), and enable the update/toggle-group-icon-references branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/toggle-group-icon-references

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

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

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/packages/fields/src/field-toggle-group/toggle-group-field.tsx 24/26 (92.31%) 2.83% 0 💚

Full summary · PHP report · JS report

…icon-references

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	projects/packages/premium-analytics/docs/dashboard-widgets.md
the icon-reference form ships with the field alone; widgets move to widget.json in the follow-up, and the contract takes 1.15.0 after the registry landed at 1.14.0
@retrofox retrofox added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Oct 19, 2026
@retrofox
retrofox marked this pull request as ready for review October 19, 2026 19:07
@retrofox
retrofox requested a review from a team as a code owner October 19, 2026 19:07

@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 the groundwork! @retrofox Tested well. 👍 Left a few small inline notes, nothing blocking.

Comment on lines 15 to +16
// `Option` carries no `icon`, so the icon-bearing fixtures name their own
// shape, the way the toolkit's `CHART_TYPE_ELEMENTS` are built.
type IconOption = Option & { icon: ReactElement };
// shape: an element, or a `jpa/<name>` reference as `CHART_TYPE_ELEMENTS` carries.

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.

Could we drop the CHART_TYPE_ELEMENTS reference here? After the last commit it carries React elements again, so this comment (and the one in the stories file) now describes #53778's state.

Suggested change
// `Option` carries no `icon`, so the icon-bearing fixtures name their own
// shape, the way the toolkit's `CHART_TYPE_ELEMENTS` are built.
type IconOption = Option & { icon: ReactElement };
// shape: an element, or a `jpa/<name>` reference as `CHART_TYPE_ELEMENTS` carries.
// `Option` carries no `icon`, so the icon-bearing fixtures name their own
// shape: an element or a `jpa/<name>` reference.

* @param elements - The options as the widget declares them.
* @return The options with every icon an element.
*/
export function resolveOptionIcons( elements: Option[] ): Option[] {

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.

Could resolveOptionIcons stay module-private? I couldn't find anything importing it, including the tests and #53778, so the export may read as public API nobody uses yet.

* instead of showing a blank one.
*
* @param elements - The options as the widget declares them.
* @return The options with every icon an element.

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.

nit: Would it be worth rewording @return? An unresolved reference drops its icon, so not every option comes back with an element.

Suggested change
* @return The options with every icon an element.
* @return The options, with each resolvable icon reference replaced by its element.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants