My Jetpack: migrate interstitial Buttons to @wordpress/ui#48489
Conversation
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.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryThis 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
|
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.
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).
Fixes #
Proposed changes
Follow-up to #48414. Migrates the Button imports in the My Jetpack interstitials away from
@automattic/jetpack-componentsand@wordpress/componentsto the newButtonfrom@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
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
@automattic/jetpack-components/@wordpress/components)@wordpress/ui)variant="primary"(default)variant="solid"(default)variant="secondary"variant="outline"isLoading={ … }loading={ … }fullWidthtier-ctawidth:100% classhref={ url }render={ <a href={ url } /> }+nativeButton={ false }<Link to="..."><Button/></Link>(invalid HTML)<Button render={ <Link to="..." /> } />CSS layer workaround
@wordpress/uiButton styles live inside@layer wp-ui-components. wp-admin ships an un-layereda { 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 (viarender={<a/>}orrender={<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.scssthat re-asserts--wp-ui-button-foreground-coloron anchor-rendered@wordpress/uiButtons, scoped tobody.jetpack_page_my-jetpack.Drive-bys
more-requests.jsxpreviously rendered as<a><button/></a>(invalid HTML). Moving react-router's<Link>into the Button'srenderprop produces a single, valid<a>element.Related product discussion/links
Does this pull request change what data or activity we track or use?
No. All
onClickanalytics handlers (jetpack_myjetpack_interstitial_license_link_click,jetpack_myjetpack_product_interstitial_back_link_click,jetpack_ai_upgrade_contact_us) are preserved.Testing instructions
/wp-admin/admin.php?page=my-jetpack#/add-*route on a Jetpack-connected site (e.g./add-akismet,/add-security,/add-jetpack-ai).#/add-license./add-akismet,/add-jetpack-ai), confirm the Free / Paid / Bundle tier CTAs render full-width with the right primary/outline treatment.Changelog
packages/my-jetpack— patch / changed entry covers the Button migration.