Skip to content

Performance: Migrate ToggleControl to @wordpress/components#48177

Merged
CGastrell merged 1 commit intotrunkfrom
issue-48160/migrate-performance-toggle-control
Apr 19, 2026
Merged

Performance: Migrate ToggleControl to @wordpress/components#48177
CGastrell merged 1 commit intotrunkfrom
issue-48160/migrate-performance-toggle-control

Conversation

@ilonagl
Copy link
Copy Markdown
Contributor

@ilonagl ilonagl commented Apr 18, 2026

Proposed changes

  • Swap the three ToggleControl usages on the Jetpack Performance settings screen off the @automattic/jetpack-components wrapper and onto @wordpress/components directly. Files: _inc/client/performance/speed-up-site.jsx, media.jsx, search.jsx.
  • Translate the wrapper's toggling prop to disabled={ toggling || existingDisabled } at each call site so click-blocking during in-flight saves is preserved.
  • Add __nextHasNoMarginBottom at each call site (the wrapper set this automatically).
  • Narrow-scope PR: the wrapper at projects/js-packages/components/components/toggle-control/ and its re-export in @automattic/jetpack-components are untouched. Dead-code cleanup, if desired, belongs in a follow-up.

Other information

Part of #48160.

The @automattic/jetpack-components ToggleControl wrapper does more than re-export the upstream primitive — it styles the track in Jetpack green, ships custom track/thumb sizing, fades opacity while saving, and optimistically flips the thumb before the API round-trip returns. @wordpress/ui has no ToggleControl yet, so this consumer lands on @wordpress/components as an interim step. Expected UX deltas on the Performance screen:

  • Thumb color when ON shifts from --jp-green-40--wp-admin-theme-color.
  • Track/thumb revert to the stock @wordpress/components FormToggle sizing.
  • No is-toggling opacity fade while a setting is saving.
  • No optimistic thumb flip — the thumb moves only after the save resolves. Click-blocking is preserved via disabled.

Screenshots

Surface Before (baseline on JN) After (this branch on JN)
Performance settings screen before after

JN rsync target: plugins/jetpack · Baseline: current JN state with Jetpack connected · JN site: thoughtfully-remarkable-device.jurassic.ninja

Testing instructions

  • Visit Jetpack → Settings → Performance in wp-admin.
  • Performance & speed section: click Enable site accelerator. Confirm that during the save the toggle is not clickable again (click-blocking preserved) and that the thumb moves after the save resolves. Turn it off again to confirm the round-trip in both directions.
  • Media → VideoPress: enable VideoPress via the module toggle, then flip Video Privacy: Restrict views to members of this site. Confirm click-blocking during save.
  • Search (paid feature): with Jetpack Search + Instant Search available, flip Enable instant search experience. Confirm click-blocking during save and that the toggle is disabled while the parent Search module is saving.
  • No console warnings about __nextHasNoMarginBottom or deprecated props on the Performance screen.
  • Changelog entry added for plugins/jetpack (other/patch).

Direct swap of the three ToggleControl usages on the Jetpack Performance
settings screen off the @automattic/jetpack-components wrapper onto the
upstream @wordpress/components primitive. Preserves click-blocking during
save operations by merging the wrapper's `toggling` prop into the existing
`disabled` prop. Part of #48160.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 18, 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 issue-48160/migrate-performance-toggle-control branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack issue-48160/migrate-performance-toggle-control

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

@ilonagl ilonagl self-assigned this Apr 18, 2026
@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Admin Page React-powered dashboard under the Jetpack menu labels Apr 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 18, 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 🤖


🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so:

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

My PR adds *x* and *y*.

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: May 5, 2026
    • Code freeze: May 4, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@ilonagl ilonagl requested review from enejb, lezama and simison April 18, 2026 21:22
@jp-launch-control
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

Copy link
Copy Markdown
Contributor

@nerrad nerrad left a comment

Choose a reason for hiding this comment

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

Code looks okay. This does change behaviour of the toggle though where it isn't actually toggled until the action completes successfully. On slow connections or saving actions that are slower, that does mean the only feedback the user will have is the disabled button and the toast notification. Arguably, this could be better than an optimistic toggle and then it unsets on unsuccessful saves.

I don't know whether in practice this is a big deal though, and the loss of the optimistic saves is already noted in the PR description, so I'll preapprove.

@CGastrell CGastrell added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Apr 19, 2026
@CGastrell CGastrell marked this pull request as ready for review April 19, 2026 14:59
@github-actions github-actions bot added [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Apr 19, 2026
Copy link
Copy Markdown
Contributor

@CGastrell CGastrell left a comment

Choose a reason for hiding this comment

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

LGTM! Concern raised by @nerrad is legit, but this is already handling the possible "is toggling" state through disabled state.

Worth keeping this in mind if we're gonna turn the settings behavior to an optimistic approach.

@CGastrell CGastrell merged commit caad88e into trunk Apr 19, 2026
79 checks passed
@CGastrell CGastrell deleted the issue-48160/migrate-performance-toggle-control branch April 19, 2026 15:28
@github-actions github-actions bot removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Apr 19, 2026
@github-actions github-actions bot added this to the jetpack/15.8 milestone Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin Page React-powered dashboard under the Jetpack menu [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants