Skip to content

Charts: Replace __experimentalText with @wordpress/ui Text - #47894

Merged
adamwoodnz merged 2 commits into
trunkfrom
cursor/CHARTS-206-text-component-migration-ed53
Apr 7, 2026
Merged

adamwoodnz merged 2 commits into
trunkfrom
cursor/CHARTS-206-text-component-migration-ed53

Conversation

@adamwoodnz

@adamwoodnz adamwoodnz commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

Migrate the Text component usage from the experimental __experimentalText export in @wordpress/components to the stable Text component from @wordpress/ui.

  • leaderboard-chart.tsx (production): Import Text from @wordpress/ui alongside the existing Stack import, removing it from the @wordpress/components import (which still imports __experimentalGrid)
  • donut.stories.tsx (stories): Import Text from @wordpress/ui, renaming the visx SVG text import to SvgText to avoid collision. Props adapted from the @wordpress/components API to @wordpress/ui:
    • size="small" → variant="body-sm"
    • weight={600} → style={{ fontWeight: 600 }}

Other information

  • @wordpress/ui v0.9.0 is already a production dependency of @automattic/charts
  • @wordpress/components remains as a devDependency for other experimental components (__experimentalGrid, __experimentalHStack) — those migrations are tracked separately (e.g., CHARTS-175 for HStack)
  • The eslint-disable @wordpress/no-unsafe-wp-apis comment is preserved in both files since other experimental imports remain

Related product discussion/links

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

No.

Testing instructions

  1. Run typecheck: cd projects/js-packages/charts && pnpm run typecheck — should pass with no errors
  2. Run tests: cd projects/js-packages/charts && pnpm run test — all 841 tests should pass
  3. Run build: cd projects/js-packages/charts && pnpm run build — should build successfully
  4. Verify in Storybook that the Leaderboard Chart and Donut Chart stories render correctly (text elements should appear with proper styling)

Linear Issue: CHARTS-206

Open in Web Open in Cursor 

Replace usage of __experimentalText from @wordpress/components with the
stable Text component from @wordpress/ui in leaderboard-chart.tsx
(production code) and donut.stories.tsx (stories).

- leaderboard-chart.tsx: Import Text from @wordpress/ui alongside Stack
- donut.stories.tsx: Import Text as WPText from @wordpress/ui, migrate
  size/weight props to variant/style equivalents

CHARTS-206
@github-actions

github-actions Bot commented Apr 2, 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 cursor/CHARTS-206-text-component-migration-ed53 branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack cursor/CHARTS-206-text-component-migration-ed53

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 commented Apr 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!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Apr 2, 2026
@adamwoodnz adamwoodnz self-assigned this Apr 2, 2026
@adamwoodnz adamwoodnz removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Apr 2, 2026
@adamwoodnz

Copy link
Copy Markdown
Contributor Author

@cursoragent I'd prefer to drop the WPText rename and just use Text. Is there a reason to keep it?

@cursor

cursor Bot commented Apr 2, 2026 •

Copy link
Copy Markdown

Done. The WPText alias was there to avoid a name collision with the visx Text import (the SVG text component used for donut center labels). I flipped the aliasing — now @wordpress/ui's Text gets the clean name and the visx import is aliased to SvgText, which is more descriptive anyway. Typecheck and all 841 tests pass.

Open in Web Open in Cursor 

Rename the visx SVG text import to SvgText to free the Text name for
the @wordpress/ui component, avoiding the need for a WPText alias.
@jp-launch-control

jp-launch-control Bot commented Apr 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 · JS report

@simison

simison commented Apr 2, 2026

Copy link
Copy Markdown
Member

Careful with this component; it's not fully recommended to use it yet. In some situations it works, but review carefully that it's not inheriting e.g. CSS overrides and such.
See:

@adamwoodnz

Copy link
Copy Markdown
Contributor Author

Careful with this component; it's not fully recommended to use it yet. In some situations it works, but review carefully that it's not inheriting e.g. CSS overrides and such.

Tested in Woo Analytics in CIAB Admin and no overrides are present. No other product uses Leaderboard Chart afaik yet.

Screenshot 2026-04-07 at 4 58 49 PM

@adamwoodnz

Copy link
Copy Markdown
Contributor Author

@claude review please

@adamwoodnz
adamwoodnz marked this pull request as ready for review April 7, 2026 05:00
@adamwoodnz adamwoodnz added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Apr 7, 2026
@adamwoodnz
adamwoodnz requested review from a team and Copilot April 7, 2026 05:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates usage of the experimental __experimentalText export from @wordpress/components to the stable Text component from @wordpress/ui within the Charts package, reducing reliance on unsafe/experimental APIs while keeping other experimental imports unchanged.

Changes:

  • Update leaderboard-chart.tsx to import Text from @wordpress/ui (while keeping __experimentalGrid from @wordpress/components).
  • Update donut.stories.tsx to import Text from @wordpress/ui, rename the visx Text import to SvgText, and adapt legend text props to the @wordpress/ui API.
  • Add a changelog fragment documenting the migration.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
projects/js-packages/charts/src/charts/pie-chart/stories/donut.stories.tsx Switch legend text to @wordpress/ui Text, avoid name collision by renaming visx text to SvgText, and update props accordingly.
projects/js-packages/charts/src/charts/leaderboard-chart/leaderboard-chart.tsx Replace experimental Text import with stable @wordpress/ui Text while keeping experimental grid usage.
projects/js-packages/charts/changelog/text-component-migration Add changelog entry describing the Text component migration.

@adamwoodnz

Copy link
Copy Markdown
Contributor Author

PR Review (quick depth — 58 lines, 1 project)

Verdict: Looks good — ready to merge.

Summary

Migrates Text from @wordpress/components's experimental export to the stable @wordpress/ui Text in leaderboard-chart.tsx and donut.stories.tsx. Prop adaptation (size="small" → variant="body-sm", weight={600} → style={{ fontWeight: 600 }}) and visx Text aliased to SvgText to avoid collision.

Checks

  • Changelog: present and valid (text-component-migration, patch/changed).
  • Dependency: @wordpress/ui@0.9.0 confirmed as a production dep in package.json — migration doesn't shift weight onto a devDep.
  • Import collision: visx Text correctly aliased to SvgText; all 4 story usages updated consistently.
  • Prop translation: weight={600} merges cleanly into the existing style object on the bold legend cell, preserving textAlign: 'right'.
  • eslint-disable: @wordpress/no-unsafe-wp-apis retained — still needed for remaining __experimentalGrid / __experimentalHStack.
  • Backward compat: no public API surface changes.
  • Security / a11y / RTL / i18n: no relevant changes.

Findings

No blockers, no suggestions.


Reviewed by Claude Code (Opus 4.6) — quick depth. JS tests not run; follow PR testing instructions to verify locally.

@adamwoodnz
adamwoodnz merged commit 127ba47 into trunk Apr 7, 2026
98 checks passed
@adamwoodnz
adamwoodnz deleted the cursor/CHARTS-206-text-component-migration-ed53 branch April 7, 2026 21:55
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Apr 7, 2026
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.

4 participants