Skip to content

ModuleToggle: import ToggleControl from @wordpress/components - #48197

Merged
CGastrell merged 1 commit into
trunkfrom
update/module-toggle-wp-components
Apr 24, 2026
Merged

CGastrell merged 1 commit into
trunkfrom
update/module-toggle-wp-components

Conversation

@CGastrell

@CGastrell CGastrell commented Apr 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #

Proposed changes

Continues the migration started in #48177 / #48179 / #48189 / #48190 / #48186 by moving the underlying ToggleControl of the shared ModuleToggle wrapper from @automattic/jetpack-components to @wordpress/components.

  • module-toggle/index.jsx: import ToggleControl from @wordpress/components, add __nextHasNoMarginBottom (matches the wrapper's prior default and avoids a deprecation warning), and stop forwarding the toggling prop (not present on the upstream component).
  • Remove the now-dead toggling=... prop from every <ModuleToggle> consumer in the Jetpack settings UI (~32 call sites across 26 files: Dashboard At-a-Glance card, plus Security / Performance / Writing / Sharing / Discussion / Traffic / Reader / Monetize / Newsletter settings).
  • For each consumer, the saving condition that was on toggling= is now folded into the existing disabled expression so click-blocking during a save is preserved. Each call site was inspected individually to combine the new condition with whatever was already in disabled (offline mode, owner connection, plugin conflicts, etc.) — not a bulk find/replace.

The only user-visible loss is the brief optimistic-flip / dim animation during the save round-trip — same trade-off accepted in the previous PRs.

Direct <ToggleControl> consumers that still import from @automattic/jetpack-components (newsletter/subscriptions-settings.jsx, the inner toggles in earn/ads.jsx, line 170 of newsletter/newsletter.jsx) are intentionally left alone — they belong to a separate follow-up.

Related product discussion/links

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

No.

Testing instructions

  1. Open wp-admin/admin.php?page=jetpack#/dashboard and confirm the At-a-Glance toggles (Brute force protection, Downtime monitoring, Image Accelerator, Search, VideoPress, etc.) render and toggle correctly.
  2. Walk every Settings tab and confirm each ModuleToggle row renders with the same spacing/styling as before and that flipping the toggle still saves cleanly:
    • Security (Downtime monitoring, Account protection, Brute force protection, Always allowed IPs, WordPress.com login)
    • Performance (Search, Site accelerator, Speed up image/static load times, VideoPress, Video Privacy)
    • Writing (Carousel, Composing × 5, Widgets × 2, Post by Email)
    • Sharing (Jetpack Social, Sharing buttons, Like buttons)
    • Discussion (Comments, Gravatar hovercards, Comment Likes)
    • Traffic (Related Posts, SEO, Stats, Blaze, Shortlinks, Sitemaps, Site Verification, Canonical URLs)
    • Reader (Add a link to the Reader)
    • Monetize (Ads)
    • Newsletter (?page=jetpack-newsletter)
  3. Toggle one module on/off — verify the toggle becomes disabled while the save is in flight (mouse cursor + visual disabled state), and re-enables when the save completes. The previous "optimistic flip + dim" animation is intentionally gone.
  4. With JETPACK_DEV_DEBUG enabled, set a module override (e.g. jetpack_active_modules filter) and confirm the override-disabled state and "managed by a site administrator" help text still appear on the corresponding ModuleToggle.

Real-screen before / after

Captured on a live local dev site at 1440×900. Pixel diff between baseline (trunk) and this PR is ≈0% on every page (the only diffs are unrelated drift in the Jetpack sidebar notification badge and the live Stats chart).

Page Before After
Dashboard (At a Glance) before-dashboard dashboard
Security before-security security
Performance before-performance performance
Writing before-writing writing
Sharing before-sharing sharing
Discussion before-discussion discussion
Traffic before-traffic traffic
Reader before-reader reader
Monetize before-monetize monetize
Newsletter before-newsletter newsletter

@github-actions

github-actions Bot commented Apr 20, 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/module-toggle-wp-components branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/module-toggle-wp-components

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 added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Admin Page React-powered dashboard under the Jetpack menu labels Apr 20, 2026
@github-actions

github-actions Bot commented Apr 20, 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!


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.

@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 20, 2026
@jp-launch-control

jp-launch-control Bot commented Apr 20, 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

@CGastrell CGastrell added [Status] Needs Review This PR is ready for review. 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 Apr 20, 2026
@CGastrell CGastrell self-assigned this Apr 20, 2026
CGastrell added a commit that referenced this pull request Apr 23, 2026
…48207)

Migrate the 10 direct <ToggleControl> call sites in the Monetize (Ads)
settings off the @automattic/jetpack-components wrapper and onto
@wordpress/components, matching PRs #48177 / #48179 / #48189 / #48190
/ #48186.

- Split the import so ToggleControl comes from @wordpress/components
  alongside ExternalLink.
- Add __nextHasNoMarginBottom on every call site so margin matches the
  prior default and no deprecation warning fires.
- Drop the toggling prop (not present on the upstream component) and
  fold each option key into the existing disabled clause alongside
  'wordads', so click-blocking during a save is preserved. The only
  user-visible loss is the short optimistic-flip / dim animation.

The <ModuleToggle slug="wordads"> above these toggles is intentionally
left alone -- it belongs to the ModuleToggle migration in PR #48197.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Switch the ToggleControl rendered by the shared ModuleToggle wrapper
from @automattic/jetpack-components to @wordpress/components, in line
with PRs #48177 / #48179 / #48189 / #48190 / #48186.

- Add __nextHasNoMarginBottom so spacing matches the prior wrapper
  default and no deprecation warning fires.
- Drop the wrapper toggling prop (not present on the upstream
  component) and remove the now-dead toggling= lines from every
  <ModuleToggle> consumer. For each consumer, the saving condition
  was folded into the existing disabled expression so click-blocking
  during a save is preserved (only the optimistic-flip / dim animation
  is lost). Each call site was inspected individually rather than
  bulk-edited.

Direct <ToggleControl> consumers that still import from
@automattic/jetpack-components (newsletter/subscriptions-settings, the
inner toggles in earn/ads.jsx, line 170 of newsletter/newsletter.jsx)
are intentionally left alone -- separate follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CGastrell
CGastrell force-pushed the update/module-toggle-wp-components branch from 385233a to e7c27cc Compare April 24, 2026 13:01
@CGastrell
CGastrell merged commit 5849955 into trunk Apr 24, 2026
72 checks passed
@CGastrell
CGastrell deleted the update/module-toggle-wp-components branch April 24, 2026 13:34
@github-actions github-actions Bot added this to the jetpack/15.8 milestone Apr 24, 2026
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Apr 24, 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.

1 participant