Skip to content

My Jetpack: migrate interstitial Buttons to @wordpress/ui#48489

Merged
CGastrell merged 2 commits into
trunkfrom
feat/mj-interstitial-buttons-wp-ui
May 5, 2026
Merged

My Jetpack: migrate interstitial Buttons to @wordpress/ui#48489
CGastrell merged 2 commits into
trunkfrom
feat/mj-interstitial-buttons-wp-ui

Conversation

@CGastrell
Copy link
Copy Markdown
Contributor

@CGastrell CGastrell commented May 4, 2026

Fixes #

Proposed changes

Follow-up to #48414. Migrates the Button imports in the My Jetpack interstitials away from @automattic/jetpack-components and @wordpress/components to the new Button from @wordpress/ui, in line with the broader Jetpack UI Modernization effort.

NOTE: disregard the Dolly quotes overlapping with action buttons, that is being worked on #48472

mj-button-add-akismet-desktop mj-button-add-jetpack-ai-desktop mj-button-add-jetpack-ai-mobile mj-button-add-license-desktop mj-button-add-security-desktop mj-button-add-security-mobile mj-button-loading-state-desktop mj-button-more-requests-desktop

Files touched

  • pricing-interstitial.jsx — free / paid / bundle tier CTAs and the actions-slot "Use license key" button.
  • product-interstitial.jsx — actions-slot "Use license key" button.
  • jetpack-ai/more-requests.jsx"Contact Us" + "Back" buttons.

Prop migration

Old (@automattic/jetpack-components / @wordpress/components) New (@wordpress/ui)
variant="primary" (default) variant="solid" (default)
variant="secondary" variant="outline"
isLoading={ … } loading={ … }
fullWidth small tier-cta width:100% class
href={ url } render={ <a href={ url } /> } + nativeButton={ false }
<Link to="..."><Button/></Link> (invalid HTML) <Button render={ <Link to="..." /> } />

CSS layer workaround

@wordpress/ui Button styles live inside @layer wp-ui-components. wp-admin ships an un-layered a { color: var(--wp-admin-theme-color) } rule which wins over the layered button rule (un-layered styles always beat layered ones), so any Button rendered as an anchor (via render={<a/>} or render={<Link/>}) ends up with admin link blue text instead of the button's intended foreground colour — solid-variant buttons in particular render with invisible text (blue on blue).

This PR adds a single non-layered rule in _inc/style.module.scss that re-asserts --wp-ui-button-foreground-color on anchor-rendered @wordpress/ui Buttons, scoped to body.jetpack_page_my-jetpack.

Drive-bys

  • The "Back" button in more-requests.jsx previously rendered as <a><button/></a> (invalid HTML). Moving react-router's <Link> into the Button's render prop produces a single, valid <a> element.

Related product discussion/links

  • #48414 — interstitials unified header (PR being followed up)
  • #48160 — Jetpack UI Modernization tracking issue

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

No. All onClick analytics handlers (jetpack_myjetpack_interstitial_license_link_click, jetpack_myjetpack_product_interstitial_back_link_click, jetpack_ai_upgrade_contact_us) are preserved.

Testing instructions

  1. Visit each /wp-admin/admin.php?page=my-jetpack#/add-* route on a Jetpack-connected site (e.g. /add-akismet, /add-security, /add-jetpack-ai).
  2. Confirm the "Use license key" action button in the page header renders as a compact outlined button and navigates to #/add-license.
  3. On a tiered-pricing page (e.g. /add-akismet, /add-jetpack-ai), confirm the Free / Paid / Bundle tier CTAs render full-width with the right primary/outline treatment.
  4. Click any tier CTA; confirm only the clicked button shows the loading spinner while all three buttons disable until the action settles.
  5. Force-render the Jetpack AI "more requests" interstitial (it's reached when the AI request quota is exhausted). Confirm the "Contact Us" button is solid-blue with white text (the layer override is what makes that work) and that "Back" is outlined.
  6. Mobile / narrow viewport: header reflows, tier CTAs stack appropriately.

Changelog

  • packages/my-jetpack — patch / changed entry covers the Button migration.

Follow-up to #48414. Replaces the `Button` imports in the product
interstitial / pricing-interstitial / more-requests screens with the
new `Button` from `@wordpress/ui`. Affects:

- `pricing-interstitial.jsx`: free/paid/bundle tier CTAs (`isLoading`
  → `loading`, `variant="secondary"` → `variant="outline"`, `fullWidth`
  → small `tier-cta` width:100% class) and the actions-slot "Use license
  key" CTA.
- `product-interstitial.jsx`: the actions-slot "Use license key" CTA.
- `jetpack-ai/more-requests.jsx`: the "Contact Us" + "Back" buttons.

`href` cases use base-ui's `render={<a/>}` (with `nativeButton={false}`).
`@wordpress/ui` Button styles live in `@layer wp-ui-components`, which
loses to wp-admin's un-layered `a { color }` rule when rendered as an
anchor; a single non-layered rule in `_inc/style.module.scss` re-asserts
the button foreground color so anchor-rendered Buttons get the right
text color.

Also fixes invalid `<a><button/></a>` nesting on the "Back" button by
moving react-router's `<Link>` into the Button's `render` prop.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

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 feat/mj-interstitial-buttons-wp-ui branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack feat/mj-interstitial-buttons-wp-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
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

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 May 4, 2026
@jp-launch-control
Copy link
Copy Markdown

jp-launch-control Bot commented May 4, 2026

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

Coverage check overridden by Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR .

@CGastrell CGastrell self-assigned this May 4, 2026
@CGastrell CGastrell added [Status] Needs Review This PR is ready for review. Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels May 4, 2026
The non-layered `a[class*="__button"][class*="__is-"] { color: ... }`
override existed to neutralize wp-admin's un-layered `a { color }` rule
beating wp-ui's layered button color when a Button is rendered as an
anchor (`render={<a/>}`). Auditing the actually-reachable interstitials:

- Tier CTAs in pricing-interstitial render as native `<button>` (no
  `render` prop wired up on this path), so the cascade-layer issue
  doesn't apply.
- The "Use license key" action button is anchor-rendered but uses the
  outline variant — wp-admin theme blue vs. wp-ui brand blue is
  visually indistinguishable on the white background.
- The only solid-variant anchor Button in the migration lives in
  `more-requests.jsx` (`JetpackAIInterstitialMoreRequests`), which has
  zero consumers across the repo: no router entry in admin.jsx, no
  parent component imports it, and the AI store's `isOverLimit` state
  drives in-place notices on the product page rather than mounting the
  interstitial. It's unreachable code; the override was protecting a
  view that never renders.

Removing the workaround keeps the file in line with other consumer
packages and lets the next layer-aware Button consumer rely on the
upstream cascade rather than a per-package band-aid.
@CGastrell CGastrell merged commit 579a518 into trunk May 5, 2026
160 of 166 checks passed
@CGastrell CGastrell deleted the feat/mj-interstitial-buttons-wp-ui branch May 5, 2026 16:57
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label May 5, 2026
CGastrell added a commit that referenced this pull request May 22, 2026
Drop the last 5 migration-relevant @automattic/jetpack-components imports
in js-packages/connection. ActionButton's isLoading/displayError/errorMessage
behavior is preserved by mapping isLoading -> @wordpress/ui Button's loading
prop and rendering the error message as a sibling paragraph with the same
jp-action-button__error class. The default error string matches ActionButton's
default, so existing tests pass unchanged.

Keepers (DecorativeCard, getRedirectUrl, JetpackLogo, PricingCard,
TermsOfService) remain on @automattic/jetpack-components; the package
dependency stays.

Follows #48150 (Publicize), #48489 (My Jetpack interstitials), #49098
(Partner Coupon), and #48909 (CUT migration).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR [Package] My Jetpack

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant