Repository navigation
Security Settings: Import ToggleControl from @wordpress/components - #48179
Conversation
Migrate the `ToggleControl` usages in the Jetpack Security settings (WAF, Allow List, SSO) off the `@automattic/jetpack-components` wrapper and onto `@wordpress/components` directly. - Add `__nextHasNoMarginBottom` on every call site so margin matches what the wrapper was setting by default and no deprecation warning fires. - Drop the wrapper's `toggling` prop (not present on the upstream component). Existing `disabled` guards keep repeat submissions from firing while settings are in flight; the only user-visible loss is the short optimistic-flip / dim effect during the save round-trip. The `@automattic/jetpack-components` wrapper and its other consumers (including the ModuleToggle wrapper used elsewhere on the same page) are intentionally left alone — separate follow-up. Part of #48160.
|
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. 🤷 |
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>
…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>
…ts (#48197) 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>
Proposed changes
ToggleControlimport inprojects/plugins/jetpack/_inc/client/security/waf.jsx,sso.jsx, andallowList.jsxfrom@automattic/jetpack-componentsto@wordpress/components— 7 call sites total.__nextHasNoMarginBottom={ true }on every migrated<ToggleControl>so the bottom margin matches the default the jetpack-components wrapper was setting, and the upstream deprecation warning stays quiet.togglingprop from the 7 migrated sites. The upstream@wordpress/componentsToggleControlhas no equivalent. The user-visible loss is the brief optimistic knob-flip + 0.6 opacity dim during the save round-trip on WAF / Allow List / SSO toggles. See the follow-up note below for a functional gap (rapid-re-click guard) that should be closed in a later PR.Part of #48160. Follows the consumer-only migration shape of #48170 (RadioControl).
Out of scope
ToggleControlwrapper inprojects/js-packages/components/components/toggle-control/(and its re-export from the packageindex.ts) is intentionally left in place — other consumers still use it, and removing it is a separate concern.ModuleTogglewrapper at_inc/client/components/module-toggle/index.jsxalso still importsToggleControlfrom@automattic/jetpack-components; its migration will be a follow-up PR (it changes behavior foraccount-protection.jsx,monitor.jsx,protect.jsx, and the module-level rows onwaf.jsx/sso.jsx).Follow-up (to address in a later PR)
The removed
togglingprop also short-circuitedonChangewhile a save was in flight, acting as a rapid-re-click guard. The existingdisabled={ … }guards on the migrated toggles do not fully replace that:baseInputDisabledCasechecksisFetchingWafSettingsandisSavingAnyOption([ 'waf' ]), but notisUpdatingWafSettings. Those are separate Redux slices —isUpdatingWafSettingslives instate.jetpack.waf.requests(flipped byWAF_SETTINGS_UPDATE/_SUCCESS/_FAIL), whileisSavingAnyOptionreadsstate.jetpack.settings.requests.settingsSent, whichupdateWafSettingsdoes not populate. So the toggle stays enabled during the WAF-settings round-trip.togglingchecked the specific option key (jetpack_sso_match_by_email/jetpack_sso_require_two_step), butdisabledonly checks the module key (sso). Different entries insettingsSent— same gap.Impact: minor. Saves are fast (~200–500ms), duplicate updates are idempotent, and
WAF_SETTINGS_UPDATE_SUCCESSoverwrites local state with the server response (last-write-wins). Worst case is a brief UI flicker if the user rapid-clicks and responses arrive out of order. No data risk.Suggested fix in the follow-up PR:
waf.jsx/allowList.jsx: addthis.props.isUpdatingWafSettingstobaseInputDisabledCase.sso.jsx: ORisSavingAnyOption([ 'jetpack_sso_match_by_email' ])/isSavingAnyOption([ 'jetpack_sso_require_two_step' ])into each toggle'sdisabled.Does this pull request change what data or activity we track or use?
No.
Screenshots
Before / after on a live Jurassic Ninja site, with Firewall enabled so all the migrated toggles are visible. The two images are byte-identical (same SHA-256) — the change is a pure import swap with no rendered-at-rest difference. The
togglingUX regression (optimistic flip + dim) only appears during the save round-trip and cannot be captured in a static screenshot.JN rsync target:
plugins/jetpack· Baseline:trunk· JN site:thoughtfully-remarkable-device.jurassic.ninjaTesting instructions
projects/plugins/jetpack.disabled-based in-flight guard that replaces the removedtogglingprop.ToggleControlmargin-related deprecation warnings should appear.