From 8400de7443ee490d9122009a6836e43d49c45a4b Mon Sep 17 00:00:00 2001 From: Allison Levine Date: Wed, 19 Aug 2026 10:55:27 -0400 Subject: [PATCH 1/4] Newsletter: explain the paywall constraint in the Audience panel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../update-newsletter-audience-paywall-notice | 4 + .../shared/memberships/settings.jsx | 289 ++++++++++-------- .../shared/memberships/settings.scss | 14 + .../shared/memberships/test/settings-test.jsx | 164 +++++++++- 4 files changed, 339 insertions(+), 132 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/update-newsletter-audience-paywall-notice diff --git a/projects/plugins/jetpack/changelog/update-newsletter-audience-paywall-notice b/projects/plugins/jetpack/changelog/update-newsletter-audience-paywall-notice new file mode 100644 index 000000000000..6303922fea5a --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-newsletter-audience-paywall-notice @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +Newsletter: explain why the Everyone audience is unavailable when a post has a paywall block, instead of linking to the block. diff --git a/projects/plugins/jetpack/extensions/shared/memberships/settings.jsx b/projects/plugins/jetpack/extensions/shared/memberships/settings.jsx index e32b01f9955b..68a66ec37e84 100644 --- a/projects/plugins/jetpack/extensions/shared/memberships/settings.jsx +++ b/projects/plugins/jetpack/extensions/shared/memberships/settings.jsx @@ -1,21 +1,21 @@ -import { getBlockIconComponent } from '@automattic/jetpack-shared-extension-utils'; import { formatNumberCompact } from '@automattic/number-formatters'; import { - Button, + BaseControl, Flex, FlexBlock, + Notice, RadioControl, Spinner, __experimentalToggleGroupControl as ToggleGroupControl, // eslint-disable-line @wordpress/no-unsafe-wp-apis __experimentalToggleGroupControlOption as ToggleGroupControlOption, // eslint-disable-line @wordpress/no-unsafe-wp-apis } from '@wordpress/components'; -import { useInstanceId, useViewportMatch } from '@wordpress/compose'; +import { useInstanceId } from '@wordpress/compose'; import { useEntityId, useEntityProp, store as coreDataStore } from '@wordpress/core-data'; import { useDispatch, useSelect } from '@wordpress/data'; import { PostVisibilityCheck, store as editorStore } from '@wordpress/editor'; import { __ } from '@wordpress/i18n'; -import { Icon } from '@wordpress/icons'; import { Link as ExternalLink } from '@wordpress/ui'; +import clsx from 'clsx'; import paywallBlockMetadata from '../../blocks/paywall/block.json'; import { store as membershipProductsStore } from '../../store/membership-products'; import './settings.scss'; @@ -27,8 +27,6 @@ import { } from './constants'; import { getPaidPlanLink, getShowMisconfigurationWarning, MisconfigurationWarning } from './utils'; -const paywallIcon = getBlockIconComponent( paywallBlockMetadata ); - export function Link( { href, children } ) { return ( @@ -166,6 +164,67 @@ function TierSelector() { ); } +/** + * A single audience option, rendered with Gutenberg's own RadioControl classes so it + * looks identical to a stock radio group. + * + * The group is built by hand rather than with RadioControl because an unavailable + * option has to stay visible in its natural position — "Everyone" sits above the + * options that remain selectable, which is a place RadioControl gives no way to reach. + * + * Unavailable options use aria-disabled rather than the native disabled attribute: a + * disabled input leaves the tab order and is skipped by screen readers, which would + * hide the option from exactly the people its explanation is there to inform. They are + * also left out of the shared group name, so arrow-key navigation — which selects as it + * moves — cannot land on one and choose it. + * + * @param {object} props - Component props. + * @param {string} props.id - Unique id tying the input to its label. + * @param {string} props.groupName - Shared name for the selectable options. + * @param {string} props.value - Access level key this option sets. + * @param {string} props.label - Visible label. + * @param {boolean} props.checked - Whether this option is the current value. + * @param {boolean} props.disabled - Whether this option cannot be chosen. + * @param {string} [props.describedBy] - Id of the element explaining why it is unavailable. + * @param {Function} props.onChange - Called with the new access level key. + * @return {import('react').ReactElement} The option. + */ +function AccessOption( { id, groupName, value, label, checked, disabled, describedBy, onChange } ) { + return ( +
+ onChange( event.target.value ) } + onClick={ disabled ? event => event.preventDefault() : undefined } + onKeyDown={ + disabled + ? event => { + if ( event.key === ' ' ) { + event.preventDefault(); + } + } + : undefined + } + /> + +
+ ); +} + export function NewsletterAccessRadioButtons( { accessLevel, hasTierPlans, @@ -186,6 +245,15 @@ export function NewsletterAccessRadioButtons( { // paid before Stripe was disconnected does not end up with nothing selected. const showPaidAsDisabled = ! isPaidAvailable && ! isPaidSelected; + // A paywall block splits the post, so "the whole post is public" stops being an + // option it can express. The option stays visible and disabled — the same treatment + // paid subscribers gets — with a notice saying why, rather than the panel silently + // changing shape. The saved-value guard is the same as above: the paywall block + // moves the post off "everybody" when it is inserted, but until that lands we must + // not leave the group with nothing selected. + const isEverybodySelected = accessLevel === accessOptions.everybody.key; + const showEverybodyAsDisabled = !! postHasPaywallBlock && ! isEverybodySelected; + const setAccess = useSetAccess(); // The count beside each option is the size of the audience that can read it, which // is what distinguishes the options from one another. postHasPaywallBlock is @@ -203,78 +271,79 @@ export function NewsletterAccessRadioButtons( { paidSubscribers, } ); - const paidOptionLabel = `${ accessOptions.paid_subscribers.label } (${ formatNumberCompact( - paidSubscribersReach - ) })`; - const disabledPaidOptionId = useInstanceId( - NewsletterAccessRadioButtons, - 'jetpack-newsletter-access-paid-subscribers-disabled' - ); - const setupLinkId = `${ disabledPaidOptionId }-setup-link`; + const instanceId = useInstanceId( NewsletterAccessRadioButtons, 'jetpack-newsletter-access' ); + const groupName = `${ instanceId }-group`; + const paywallNoticeId = `${ instanceId }-paywall-notice`; + const setupLinkId = `${ instanceId }-paid-setup-link`; + + const options = [ + { + value: accessOptions.everybody.key, + label: accessOptions.everybody.label, + disabled: showEverybodyAsDisabled, + describedBy: showEverybodyAsDisabled ? paywallNoticeId : undefined, + }, + { + value: accessOptions.subscribers.key, + label: `${ accessOptions.subscribers.label } (${ formatNumberCompact( subscribersReach ) })`, + }, + { + value: accessOptions.paid_subscribers.key, + label: `${ accessOptions.paid_subscribers.label } (${ formatNumberCompact( + paidSubscribersReach + ) })`, + disabled: showPaidAsDisabled, + describedBy: showPaidAsDisabled ? setupLinkId : undefined, + }, + ]; return (
- - { showPaidAsDisabled && ( - <> -
- { /* - * aria-disabled rather than disabled: a disabled input leaves the tab - * order and is skipped by screen readers, which would hide the paid - * option from exactly the people the setup link is there to inform. - * It stays focusable and announced, but cannot be selected. - */ } - event.preventDefault() } - onKeyDown={ event => { - if ( event.key === ' ' ) { - event.preventDefault(); - } - } } - id={ disabledPaidOptionId } + { showEverybodyAsDisabled && ( + + { /* + * Notice does not forward arbitrary props, so the id that "Everyone" points + * at lives on a wrapper. It covers only the copy, which keeps the visually + * hidden "Information notice" label out of the option's description. + */ } + + { __( 'Paywall active', 'jetpack' ) } +
+ { __( + 'Choose who can read the full post. Everyone can still read the content above the paywall.', + 'jetpack' + ) } +
+
+ ) } +
+ + { __( 'Who can read this post?', 'jetpack' ) } + +
+ { options.map( option => ( + - -
- - { __( 'Turn on paid subscribers', 'jetpack' ) } - - + ) ) } +
+ + { showPaidAsDisabled && ( + + { __( 'Turn on paid subscribers', 'jetpack' ) } + ) } { isPaidSelected && isPaidAvailable && }

@@ -285,7 +354,7 @@ export function NewsletterAccessRadioButtons( { } export function NewsletterAccessDocumentSettings( { accessLevel } ) { - const { hasTierPlans, stripeConnectUrl, isLoading, foundPaywallBlock } = useSelect( select => { + const { hasTierPlans, stripeConnectUrl, isLoading, postHasPaywallBlock } = useSelect( select => { const { getNewsletterTierProducts, getConnectUrl, isApiStateLoading } = select( 'jetpack/membership-products' ); @@ -295,15 +364,11 @@ export function NewsletterAccessDocumentSettings( { accessLevel } ) { isLoading: isApiStateLoading(), stripeConnectUrl: getConnectUrl(), hasTierPlans: getNewsletterTierProducts()?.length !== 0, - foundPaywallBlock: getBlocks().find( block => block.name === paywallBlockMetadata.name ), + postHasPaywallBlock: getBlocks().some( block => block.name === paywallBlockMetadata.name ), }; } ); const postVisibility = useSelect( select => select( editorStore ).getEditedPostVisibility() ); - const { selectBlock } = useDispatch( 'core/block-editor' ); - const { closeGeneralSidebar } = useDispatch( 'core/edit-post' ); - - const isMobileViewport = useViewportMatch( 'medium', '<' ); if ( isLoading ) { return ( @@ -321,54 +386,22 @@ export function NewsletterAccessDocumentSettings( { accessLevel } ) { return ( ( - <> - { foundPaywallBlock && ( - <> -

- - - -
-

{ __( 'Paywall', 'jetpack' ) }

- - { __( - 'The content below the paywall block is exclusive to the selected audience.', - 'jetpack' - ) }{ ' ' } - - -
-
- - ) } - - { showMisconfigurationWarning && } - - { canEdit && ( - - ) } - - { /* Display the uneditable access level when the user doesn't have edit privileges*/ } - { ! canEdit && { accessLabel } } - - - + + { showMisconfigurationWarning && } + + { canEdit && ( + + ) } + + { /* Display the uneditable access level when the user doesn't have edit privileges*/ } + { ! canEdit && { accessLabel } } + + ) } /> ); diff --git a/projects/plugins/jetpack/extensions/shared/memberships/settings.scss b/projects/plugins/jetpack/extensions/shared/memberships/settings.scss index 8f0233f3c581..d2a6c3de6a5a 100644 --- a/projects/plugins/jetpack/extensions/shared/memberships/settings.scss +++ b/projects/plugins/jetpack/extensions/shared/memberships/settings.scss @@ -39,6 +39,20 @@ } } + // The notice explains why "Everyone" is not selectable, so it reads as an + // introduction to the group rather than a banner floating above it. + &__paywall-notice { + margin: 0; + } + + // 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; + } + // Two tiers of spacing: the options sit close together, while the legend, the // setup link and the description are each set apart from the group by a wider // gap. Gutenberg gives the legend 8px of its own, so it needs half as much. diff --git a/projects/plugins/jetpack/extensions/shared/memberships/test/settings-test.jsx b/projects/plugins/jetpack/extensions/shared/memberships/test/settings-test.jsx index 0924554e395e..8631970476a9 100644 --- a/projects/plugins/jetpack/extensions/shared/memberships/test/settings-test.jsx +++ b/projects/plugins/jetpack/extensions/shared/memberships/test/settings-test.jsx @@ -8,6 +8,7 @@ import { Link, getAccessDescription, getReachForAccessLevelKey, + NewsletterAccessDocumentSettings, NewsletterAccessRadioButtons, NewsletterEmailDocumentSettings, } from '../settings'; @@ -334,11 +335,95 @@ describe( 'NewsletterAccessRadioButtons', () => { } ); } ); - test( 'omits Everyone when the post has a paywall block', () => { - renderPanel( { postHasPaywallBlock: true, accessLevel: 'subscribers' } ); + describe( 'when the post has a paywall block', () => { + const renderPaywalled = ( props = {}, selectOptions = {} ) => + renderPanel( + { postHasPaywallBlock: true, accessLevel: 'subscribers', ...props }, + selectOptions + ); + + // Removing the option instead would make the panel silently change shape. Keeping + // it visible and disabled matches how paid subscribers behaves when it is unavailable. + test( 'keeps Everyone visible but not selectable', () => { + renderPaywalled(); + + const everyone = screen.getByRole( 'radio', { name: 'Everyone' } ); + expect( everyone ).toHaveAttribute( 'aria-disabled', 'true' ); + expect( everyone ).not.toBeChecked(); + } ); + + test( 'does not save the everybody level when the disabled option is clicked', async () => { + renderPaywalled(); + + await userEvent.click( screen.getByRole( 'radio', { name: 'Everyone' } ) ); + expect( mockSetPostMeta ).not.toHaveBeenCalled(); + } ); + + // The notice only helps a screen reader user if the option points at it, so the + // copy is asserted through the description as it is actually computed from + // aria-describedby rather than by reading the notice on its own. + test( 'explains why Everyone is unavailable, in a way the option points at', () => { + renderPaywalled(); + + expect( screen.getByText( 'Paywall active' ) ).toBeInTheDocument(); + + const everyone = screen.getByRole( 'radio', { name: 'Everyone' } ); + expect( everyone ).toHaveAccessibleDescription( /^Paywall active/ ); + expect( everyone ).toHaveAccessibleDescription( + /Choose who can read the full post\. Everyone can still read the content above the paywall\.$/ + ); + } ); + + // A native `disabled` attribute would drop the option out of the tab order and hide + // it from screen readers, taking the explanation with it. + test( 'keeps the disabled option focusable', () => { + renderPaywalled(); + + const everyone = screen.getByRole( 'radio', { name: 'Everyone' } ); + expect( everyone ).toBeEnabled(); + + everyone.focus(); + expect( everyone ).toHaveFocus(); + } ); + + // Arrow keys select as they move within a native radio group, so an unselectable + // option must not share the group's name or it could be chosen by keyboard. + test( 'leaves the disabled option out of the keyboard group', () => { + renderPaywalled(); - expect( screen.queryByRole( 'radio', { name: 'Everyone' } ) ).not.toBeInTheDocument(); - expect( screen.getByRole( 'radio', { name: /^Subscribers/ } ) ).toBeInTheDocument(); + expect( screen.getByRole( 'radio', { name: 'Everyone' } ) ).not.toHaveAttribute( 'name' ); + expect( screen.getByRole( 'radio', { name: /^Subscribers/ } ) ).toHaveAttribute( 'name' ); + } ); + + test( 'still lets the remaining audiences be chosen', async () => { + renderPaywalled(); + + await userEvent.click( screen.getByRole( 'radio', { name: /^Paid subscribers/ } ) ); + expect( mockSetPostMeta ).toHaveBeenCalledWith( + expect.objectContaining( { + [ META_NAME_FOR_POST_LEVEL_ACCESS_SETTINGS ]: 'paid_subscribers', + } ) + ); + } ); + + // Inserting a paywall block moves the post off "everybody". Until that lands, the + // option has to stay selectable or the group would show nothing selected at all. + test( 'leaves Everyone selectable while it is still the saved value', () => { + renderPaywalled( { accessLevel: 'everybody' } ); + + const everyone = screen.getByRole( 'radio', { name: 'Everyone' } ); + expect( everyone ).toBeChecked(); + expect( everyone ).not.toHaveAttribute( 'aria-disabled' ); + } ); + } ); + + test( 'offers Everyone without explanation when there is no paywall block', () => { + renderPanel( { accessLevel: 'everybody' } ); + + const everyone = screen.getByRole( 'radio', { name: 'Everyone' } ); + expect( everyone ).toBeChecked(); + expect( everyone ).not.toHaveAttribute( 'aria-disabled' ); + expect( screen.queryByText( 'Paywall active' ) ).not.toBeInTheDocument(); } ); // The counts report how many people can read each level. Switching the paid count to @@ -355,6 +440,77 @@ describe( 'NewsletterAccessRadioButtons', () => { } ); } ); +describe( 'NewsletterAccessDocumentSettings', () => { + const PAYWALL_BLOCK = { name: 'jetpack/paywall', clientId: 'paywall-1' }; + + const createMockSelect = + ( { blocks = [] } = {} ) => + store => { + if ( store === 'jetpack/membership-products' ) { + return { + isApiStateLoading: () => false, + getConnectUrl: () => null, + getNewsletterTierProducts: () => [], + }; + } + if ( store === 'core/block-editor' ) { + return { getBlocks: () => blocks }; + } + if ( store === membershipProductsStore ) { + return { + getSubscriberCounts: () => ( { totalSubscribers: 10, paidSubscribers: 2 } ), + getNewsletterTierProducts: () => [], + }; + } + if ( store === editorStore ) { + return { + getCurrentPostType: () => 'post', + getEditedPostVisibility: () => 'public', + }; + } + return {}; + }; + + const renderSettings = ( { blocks = [], accessLevel = 'subscribers' } = {} ) => { + mockUseSelect.mockImplementation( selector => selector( createMockSelect( { blocks } ) ) ); + return render( ); + }; + + beforeEach( () => { + jest.clearAllMocks(); + mockUseEntityProp.mockReturnValue( [ {}, jest.fn() ] ); + jest.spyOn( wpData, 'useSelect' ).mockImplementation( selector => mockUseSelect( selector ) ); + } ); + + afterEach( () => { + jest.restoreAllMocks(); + } ); + + // The card used to sit above the radio group with an "Edit the block." button that + // selected the paywall block without switching the sidebar to the Block tab, so it + // looked inert. The notice explains the constraint instead. Asserting the notice is + // present is what makes the card's absence meaningful: it proves the paywall block + // was detected in this render, rather than the card being missing for some other reason. + test( 'explains the paywall in the panel instead of linking out to the block', () => { + renderSettings( { blocks: [ PAYWALL_BLOCK ] } ); + + expect( screen.getByText( 'Paywall active' ) ).toBeInTheDocument(); + expect( screen.queryByRole( 'button', { name: /edit the block/i } ) ).not.toBeInTheDocument(); + expect( + screen.queryByText( /content below the paywall block is exclusive/i ) + ).not.toBeInTheDocument(); + } ); + + test( 'leaves Everyone selectable when the post has no paywall block', () => { + renderSettings( { blocks: [ { name: 'core/paragraph', clientId: 'p-1' } ] } ); + + expect( screen.getByRole( 'radio', { name: 'Everyone' } ) ).not.toHaveAttribute( + 'aria-disabled' + ); + expect( screen.queryByText( 'Paywall active' ) ).not.toBeInTheDocument(); + } ); +} ); + describe( 'NewsletterEmailDocumentSettings', () => { const createMockSelect = postEmailSentState => store => { if ( store === editorStore ) { From 5f3e1b480fb6d7ca93715ab124826ca57a0ea103 Mon Sep 17 00:00:00 2001 From: Allison Levine Date: Wed, 19 Aug 2026 10:55:43 -0400 Subject: [PATCH 2/4] Newsletter: drop the redundant panelHeading from accessOptions 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) --- .../plugins/jetpack/extensions/blocks/subscriptions/panel.jsx | 2 +- .../plugins/jetpack/extensions/shared/memberships/constants.js | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.jsx b/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.jsx index a131c88bc9d0..cee8bb46a295 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.jsx +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/panel.jsx @@ -174,7 +174,7 @@ function NewsletterPrePublishSettingsPanel( { accessLevel, showPreviewModal } ) { __( 'Audience:', 'jetpack' ) } { accessLevel && ( - { accessOptions[ accessLevel ].panelHeading } + { accessOptions[ accessLevel ].label } ) } diff --git a/projects/plugins/jetpack/extensions/shared/memberships/constants.js b/projects/plugins/jetpack/extensions/shared/memberships/constants.js index 69f7f90af846..e843ffdffe88 100644 --- a/projects/plugins/jetpack/extensions/shared/memberships/constants.js +++ b/projects/plugins/jetpack/extensions/shared/memberships/constants.js @@ -7,16 +7,13 @@ export const accessOptions = { everybody: { key: 'everybody', label: __( 'Everyone', 'jetpack' ), - panelHeading: __( 'Everyone', 'jetpack' ), }, subscribers: { key: 'subscribers', label: __( 'Subscribers', 'jetpack' ), - panelHeading: __( 'Subscribers', 'jetpack' ), }, paid_subscribers: { key: 'paid_subscribers', label: __( 'Paid subscribers', 'jetpack' ), - panelHeading: __( 'Paid subscribers', 'jetpack' ), }, }; From 03d135f16774b6b35842083b375a7b9fe2451967 Mon Sep 17 00:00:00 2001 From: Allison Levine Date: Wed, 19 Aug 2026 11:23:05 -0400 Subject: [PATCH 3/4] Newsletter: use the @wordpress/ui Notice for the paywall notice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 and a
. 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) --- .../shared/memberships/settings.jsx | 25 ++++++------------- .../shared/memberships/settings.scss | 6 ----- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/projects/plugins/jetpack/extensions/shared/memberships/settings.jsx b/projects/plugins/jetpack/extensions/shared/memberships/settings.jsx index 68a66ec37e84..da7b167a80f3 100644 --- a/projects/plugins/jetpack/extensions/shared/memberships/settings.jsx +++ b/projects/plugins/jetpack/extensions/shared/memberships/settings.jsx @@ -3,7 +3,6 @@ import { BaseControl, Flex, FlexBlock, - Notice, RadioControl, Spinner, __experimentalToggleGroupControl as ToggleGroupControl, // eslint-disable-line @wordpress/no-unsafe-wp-apis @@ -14,7 +13,7 @@ import { useEntityId, useEntityProp, store as coreDataStore } from '@wordpress/c import { useDispatch, useSelect } from '@wordpress/data'; import { PostVisibilityCheck, store as editorStore } from '@wordpress/editor'; import { __ } from '@wordpress/i18n'; -import { Link as ExternalLink } from '@wordpress/ui'; +import { Link as ExternalLink, Notice } from '@wordpress/ui'; import clsx from 'clsx'; import paywallBlockMetadata from '../../blocks/paywall/block.json'; import { store as membershipProductsStore } from '../../store/membership-products'; @@ -300,25 +299,17 @@ export function NewsletterAccessRadioButtons( { return (
{ showEverybodyAsDisabled && ( - - { /* - * Notice does not forward arbitrary props, so the id that "Everyone" points - * at lives on a wrapper. It covers only the copy, which keeps the visually - * hidden "Information notice" label out of the option's description. - */ } - - { __( 'Paywall active', 'jetpack' ) } -
+ // icon={ null } matches the mockup, which shows the notice without the + // intent icon @wordpress/ui would otherwise render for "info". + + { __( 'Paywall active', 'jetpack' ) } + { __( 'Choose who can read the full post. Everyone can still read the content above the paywall.', 'jetpack' ) } -
-
+ + ) }
diff --git a/projects/plugins/jetpack/extensions/shared/memberships/settings.scss b/projects/plugins/jetpack/extensions/shared/memberships/settings.scss index d2a6c3de6a5a..de80a4d9b84a 100644 --- a/projects/plugins/jetpack/extensions/shared/memberships/settings.scss +++ b/projects/plugins/jetpack/extensions/shared/memberships/settings.scss @@ -39,12 +39,6 @@ } } - // The notice explains why "Everyone" is not selectable, so it reads as an - // introduction to the group rather than a banner floating above it. - &__paywall-notice { - margin: 0; - } - // 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 { From 332ca7a1a6de6397faa91bc2cca96742028000e1 Mon Sep 17 00:00:00 2001 From: Allison Levine Date: Wed, 19 Aug 2026 14:30:00 -0400 Subject: [PATCH 4/4] Newsletter: drop the paywall notice from the block's own inspector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../extensions/blocks/paywall/edit.jsx | 3 ++ .../shared/memberships/settings.jsx | 12 +++++-- .../shared/memberships/test/settings-test.jsx | 35 +++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/projects/plugins/jetpack/extensions/blocks/paywall/edit.jsx b/projects/plugins/jetpack/extensions/blocks/paywall/edit.jsx index 3b382ba8150d..18c701892617 100644 --- a/projects/plugins/jetpack/extensions/blocks/paywall/edit.jsx +++ b/projects/plugins/jetpack/extensions/blocks/paywall/edit.jsx @@ -154,6 +154,9 @@ function PaywallEdit() { stripeConnectUrl={ stripeConnectUrl } hasTierPlans={ hasTierPlans } postHasPaywallBlock={ true } + // The block card above this panel already explains the paywall, so the + // notice would only repeat the heading it sits under. + explainPaywallConstraint={ false } /> diff --git a/projects/plugins/jetpack/extensions/shared/memberships/settings.jsx b/projects/plugins/jetpack/extensions/shared/memberships/settings.jsx index da7b167a80f3..b6f8d07058de 100644 --- a/projects/plugins/jetpack/extensions/shared/memberships/settings.jsx +++ b/projects/plugins/jetpack/extensions/shared/memberships/settings.jsx @@ -229,6 +229,7 @@ export function NewsletterAccessRadioButtons( { hasTierPlans, stripeConnectUrl, postHasPaywallBlock: postHasPaywallBlock = false, + explainPaywallConstraint = true, } ) { const isStripeConnected = stripeConnectUrl === null; const { totalSubscribers, paidSubscribers } = useSelect( select => @@ -253,6 +254,13 @@ export function NewsletterAccessRadioButtons( { const isEverybodySelected = accessLevel === accessOptions.everybody.key; const showEverybodyAsDisabled = !! postHasPaywallBlock && ! isEverybodySelected; + // The paywall block's own inspector opts out: it sits directly under Gutenberg's + // block card, which already says what a paywall does, so the notice repeats the + // heading above it. Both the notice and the option's aria-describedby derive from + // this one flag — gating only the notice would leave the option pointing at an id + // that is no longer in the DOM, which reads as no description at all. + const showPaywallNotice = showEverybodyAsDisabled && explainPaywallConstraint; + const setAccess = useSetAccess(); // The count beside each option is the size of the audience that can read it, which // is what distinguishes the options from one another. postHasPaywallBlock is @@ -280,7 +288,7 @@ export function NewsletterAccessRadioButtons( { value: accessOptions.everybody.key, label: accessOptions.everybody.label, disabled: showEverybodyAsDisabled, - describedBy: showEverybodyAsDisabled ? paywallNoticeId : undefined, + describedBy: showPaywallNotice ? paywallNoticeId : undefined, }, { value: accessOptions.subscribers.key, @@ -298,7 +306,7 @@ export function NewsletterAccessRadioButtons( { return (
- { showEverybodyAsDisabled && ( + { showPaywallNotice && ( // icon={ null } matches the mockup, which shows the notice without the // intent icon @wordpress/ui would otherwise render for "info". diff --git a/projects/plugins/jetpack/extensions/shared/memberships/test/settings-test.jsx b/projects/plugins/jetpack/extensions/shared/memberships/test/settings-test.jsx index 8631970476a9..906d45009f72 100644 --- a/projects/plugins/jetpack/extensions/shared/memberships/test/settings-test.jsx +++ b/projects/plugins/jetpack/extensions/shared/memberships/test/settings-test.jsx @@ -414,6 +414,41 @@ describe( 'NewsletterAccessRadioButtons', () => { const everyone = screen.getByRole( 'radio', { name: 'Everyone' } ); expect( everyone ).toBeChecked(); expect( everyone ).not.toHaveAttribute( 'aria-disabled' ); + expect( screen.queryByText( 'Paywall active' ) ).not.toBeInTheDocument(); + } ); + + // The paywall block's own inspector opts out, because Gutenberg's block card + // directly above it already explains the paywall. + describe( 'when the caller opts out of the explanation', () => { + const renderOptedOut = () => renderPaywalled( { explainPaywallConstraint: false } ); + + test( 'hides the notice but keeps Everyone visible and disabled', () => { + renderOptedOut(); + + expect( screen.queryByText( 'Paywall active' ) ).not.toBeInTheDocument(); + expect( screen.getByRole( 'radio', { name: 'Everyone' } ) ).toHaveAttribute( + 'aria-disabled', + 'true' + ); + } ); + + // Gating the notice without gating aria-describedby would leave the option + // pointing at an id that is no longer rendered, which assistive tech reports as + // no description at all — worse than deliberately having none. + test( 'leaves no dangling description reference behind', () => { + renderOptedOut(); + + const everyone = screen.getByRole( 'radio', { name: 'Everyone' } ); + expect( everyone ).not.toHaveAttribute( 'aria-describedby' ); + expect( everyone ).toHaveAccessibleDescription( '' ); + } ); + + test( 'still refuses to save the everybody level', async () => { + renderOptedOut(); + + await userEvent.click( screen.getByRole( 'radio', { name: 'Everyone' } ) ); + expect( mockSetPostMeta ).not.toHaveBeenCalled(); + } ); } ); } );