Repository navigation
ModuleToggle: import ToggleControl from @wordpress/components - #48197
Conversation
|
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! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
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. 🤷 |
…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>
385233a to
e7c27cc
Compare
Fixes #
Proposed changes
Continues the migration started in #48177 / #48179 / #48189 / #48190 / #48186 by moving the underlying
ToggleControlof the sharedModuleTogglewrapper from@automattic/jetpack-componentsto@wordpress/components.module-toggle/index.jsx: importToggleControlfrom@wordpress/components, add__nextHasNoMarginBottom(matches the wrapper's prior default and avoids a deprecation warning), and stop forwarding thetogglingprop (not present on the upstream component).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).toggling=is now folded into the existingdisabledexpression so click-blocking during a save is preserved. Each call site was inspected individually to combine the new condition with whatever was already indisabled(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 inearn/ads.jsx, line 170 ofnewsletter/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
wp-admin/admin.php?page=jetpack#/dashboardand confirm the At-a-Glance toggles (Brute force protection, Downtime monitoring, Image Accelerator, Search, VideoPress, etc.) render and toggle correctly.ModuleTogglerow renders with the same spacing/styling as before and that flipping the toggle still saves cleanly:?page=jetpack-newsletter)disabledwhile 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.JETPACK_DEV_DEBUGenabled, set a module override (e.g.jetpack_active_modulesfilter) and confirm the override-disabled state and "managed by a site administrator" help text still appear on the correspondingModuleToggle.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).