Repository navigation
Newsletter: explain the paywall constraint in the Audience panel - #51394
Conversation
When a post contains a paywall block, the Audience panel dropped "Everyone" from the radio group and put a Paywall card above it whose "Edit the block." button selected the block without switching the sidebar to the Block tab, so on desktop it looked inert. In the pre-publish panel it was worse: the publish sidebar covers the canvas, so it selected a block the user could not see. Rather than fix the link, remove what it was compensating for. "Everyone" now stays visible and disabled — the treatment "Paid subscribers" already gets when paid subscriptions are not set up — with a notice above the group saying why it cannot be chosen. The panel keeps its shape and the constraint is stated where it applies. The group is now built by hand instead of by RadioControl, because a disabled "Everyone" has to sit between the legend and the remaining options, which RadioControl gives no way to reach. It reuses RadioControl's own classes, and folds in the disabled-option markup that was already hand-rolled for the paid option. Disabled options keep the existing contract: aria-disabled rather than the native attribute, so they stay focusable and announced, and no shared group name, so arrow keys cannot land on one and select it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Every accessOptions entry carried a panelHeading identical, character for character, to its label. The field had one consumer, the pre-publish panel header, which now reads label instead. No translation churn: label carries the same strings, so this removes three duplicate __() call sites and no message ids. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
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 SummaryCoverage changed in 1 file.
|
The design shows a bordered, rounded notice with a bold title above the body.
That is @wordpress/ui's Notice, which has Title and Description slots for
exactly this shape and carries its own styles in the bundle.
The first pass used @wordpress/components' Notice and faked the title with a
<strong> and a <br>. That renders as WP core's older `.components-notice` — a
white box with a 4px left bar — because @wordpress/components is an external
resolved to whatever the site's WordPress ships, so the styling drifts by WP
version. @wordpress/ui is bundled here, so the notice looks the same
everywhere. Boost already uses it this way, and this file already imports Link
from the same package.
Notice.Root forwards arbitrary props, so the id "Everyone" points at now sits
on the notice itself and the wrapper span is gone. Dropped the SCSS margin
override with it: the component already has no margin, so the rule did nothing.
icon={ null } suppresses the intent icon, to match the mockup.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The paywall block's Content access panel renders directly beneath Gutenberg's
block card, which already reads "Paywall — Limit access to the content below
this block to chosen subscribers." Stacking the notice under that gave the panel
four blocks of prose, three of them about the paywall, with "Paywall active"
sitting immediately under a heading that says "Paywall" — and pushed the radio
options, the reason to open the panel, below the visible area.
The document sidebar and pre-publish panel keep the notice; only the block
inspector opts out, via explainPaywallConstraint={ false }.
The notice and the option's aria-describedby now derive from a single flag.
Gating just the notice would leave "Everyone" pointing at an id no longer in the
DOM, which assistive tech reports as no description at all — worse than
deliberately having none. A test pins that: the naive two-flag version fails it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
| // The group is built by hand rather than by RadioControl (see AccessOption), | ||
| // so it supplies the spacing RadioControl would get from its own VStack. | ||
| .components-radio-control__group-wrapper { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 12px; | ||
| } |
There was a problem hiding this comment.
You could just use Stack component and not need these styles.
There was a problem hiding this comment.
Good call — Stack is in the bundled @wordpress/ui we're already importing from here. Scope is smaller than it looks: it replaces the __group-wrapper block only, and the legend spacing, disabled opacity and description styles stay either way. I'll fold it into next PR.
| return ( | ||
| <div | ||
| className={ clsx( 'components-radio-control__option', { | ||
| 'jetpack-newsletter-access-radio-buttons__disabled-option': disabled, | ||
| } ) } | ||
| > | ||
| <input | ||
| type="radio" |
There was a problem hiding this comment.
The radio group is now built by hand rather than by RadioControl. A disabled Everyone has to sit between the legend and the remaining options, which RadioControl gives no way to reach — it has no per-option disabled.
Have you looked into whether this could be improved upstream and accomplished that way? That would be ideal.
I'm worried about the implementation; it's relying on styles from upstream which can change (the whole CSS selector can disappear, and cannot be relied upon as stable API), and that nothing ever changes upstream also in the structure of the HTML that the styles apply to. That's sorta fragile and would break quietly.
If you really need to manually rebuild the component, I recommend bringing also the styles so that nothing breaks in future. Still better if there's no need to re-implement core components tho. :-)
There was a problem hiding this comment.
Have you looked into whether this could be improved upstream […] it's relying on styles from upstream which can change
Fair, and you're right that the coupling is the weak point. Filed it upstream: WordPress/gutenberg#81939.
Some of what I found while writing it up, since it affects how much this can actually be fixed here:
- Per-option
disabledwas implemented upstream once already, in Ability to specify RadioControl options as disabled. WordPress/gutenberg#18930 (2019), and closed in 2022 without landing. It didn't get rejected — it stalled on the disabled-state styling and on screen readers disagreeing about whether a disabled radio should be arrow-key reachable. @wordpress/uihas noRadioprimitive at all yet. Radio: Add form primitive to @wordpress/ui WordPress/gutenberg#80799 tried to add one last month and was closed to coordinate with the owner of the form-primitives issue (#74178). So there wasn't a bundled component to reach for.- Even if it lands in
@wordpress/componentstomorrow, it doesn't help us for a while:wp-componentsis a runtime external (it's ineditor.asset.php's dependency list), so it resolves to whatever core ships, and Jetpack's floor isRequires at least: 7.0. We'd carry the manual path as a fallback until the floor moves past whichever release includes it.
On bringing the styles over — I looked at that and I'd push back. Core's radio-control/style.scss is 96 lines that depend on @wordpress/base-styles mixins (radio-control, button-style-outset__focus) and a chain of theme variables resolving to --wpds-*, --wp-components-color-* and --wp-admin-theme-color for the checked dot, focus ring and disabled state. Forking it trades a low-probability silent break for a guaranteed slow one: our radios freeze while every other radio in the editor keeps moving with core.
Separately — this feels like it belongs in the repo's rules rather than dying in a PR thread. Rough bullet for AGENTS.md's "Code Review Guidelines" list:
Markup that re-implements a
@wordpress/componentscomponent and reuses itscomponents-*__*class names to inherit core styling. Those selectors are not a public API, and@wordpress/componentsis a runtime external resolved to whatever WordPress core ships — so a rename degrades the UI silently on some WP versions, and no test in this repo can catch it. Check whether a bundled component (@wordpress/ui) covers the case; if the gap is genuinely upstream, note that a fix to@wordpress/componentsis unusable here until the plugin's "Requires at least" passes the release carrying it, so the local implementation stays either way.
Does that framing match how you'd put it? Happy to open a PR if so, or to defer to your wording if you'd rather write it.
There was a problem hiding this comment.
Closing the loop, upstream PR merged:
Thank you, @allilevine for filing the issue!
It will take a moment before that's available in WP supported by Jetpack but that's why it's important to get the core ball rolling early.
| import { __ } from '@wordpress/i18n'; | ||
| import { Icon } from '@wordpress/icons'; | ||
| import { Link as ExternalLink } from '@wordpress/ui'; | ||
| import { Link as ExternalLink, Notice } from '@wordpress/ui'; |
There was a problem hiding this comment.
Not related to this PR and pre-existing, but noting that the custom Link below is basically just re-implementing Link, so why not just use Link everywhere and no need this weird rename? 🙃 All the custom one does is remove text-decoration which feels like a design-smell as we should really just be able to use UI components as-is.
There was a problem hiding this comment.
Actually, the whole Link isn't used anywhere. :-) The only thing importing it is the test.
There was a problem hiding this comment.
Nice catch that it was dead entirely — thanks for cleaning it up in #51427.
Fixes NL-832
Proposed changes
When a post contains a paywall block, the Audience panel used to drop Everyone from the radio group and render a Paywall card above it:
That button called
selectBlock()but nothing switched the settings sidebar from the Document tab to the Block tab, so on desktop it looked inert.Rather than fix the link, this replaces the card with a new design discussed in p1787001127697179/1786626588.168549-slack-C03NLNTPZ2T
@wordpress/ui'sNotice, whoseTitle/Descriptionslots are exactly this shape, and which is bundled here so it renders identically regardless of the site's WordPress version. (@wordpress/components'Noticeis an external and resolves to whatever WP core ships — on WP 7.0 that is still the older left-bar style, not the design.)icon={ null }suppresses the intent icon to match the mockup — say the word if the default info icon is wanted instead.accessOptionscarried apanelHeadingfield identical, character for character, tolabelon all three entries. It had one consumer — the pre-publish panel header — which now readslabel. No translation churn:labelcarries the same strings, so this removes three duplicate__()call sites and no message ids.The radio group is now built by hand rather than by
RadioControl. A disabled Everyone has to sit between the legend and the remaining options, whichRadioControlgives no way to reach — it has no per-optiondisabled.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Requires a Jetpack-connected site (the paywall block renders a connect banner otherwise) with the
blocksandsubscriptionsmodules active./paywall).