Skip to content

Sharing & Likes: Replace "Open Site Editor" with template placement cards - #53838

Merged
jeherve merged 9 commits into
trunkfrom
add/sharing-likes-placement-cards
Oct 21, 2026
Merged

jeherve merged 9 commits into
trunkfrom
add/sharing-likes-placement-cards

Conversation

@jeherve

@jeherve jeherve commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Fixes CM-976

Proposed changes

On a block theme where the legacy buttons are off, the Sharing buttons and Like buttons sections of the React Settings > Sharing screen say "Add the … block to your theme's template." and offer an Open Site Editor button. Owners then have to find the right template, and the right spot in it, on their own.

This replaces that button with two cards per section, like the placements in Jetpack > Newsletter's Subscriptions section: one adds the section's block before the content of single posts and pages, the other after it. They save the placements #53732 added, through the same autosave as the screen's other settings.

  • Ticking a card adds the block to the single post and page templates right away, and ticking the other card moves it. Unticking it takes the block out again, except from templates someone already saved in the Site Editor.
  • A ticked card gets a "Preview and edit" link to the single post template, once its save has gone through.
  • Under the cards, a link to the page template, for owners who want pages to look different, and a line explaining that once a template is saved in the Site Editor, its blocks are moved or removed there.
  • The "Where … appear" section stays on screen while a legacy feature is still on, and its choices (Posts, Pages…) only ever applied to the legacy buttons. Whenever a section offers its block, it now says that blocks added to templates aren't affected, so unticking Pages there doesn't read as keeping the blocks off pages.
  • Each section has its own wireframe illustrations: a row of share buttons, or a Like button with a few avatars.
Sharing buttons Like buttons
Sharing buttons section with the placement cards Like buttons section with the placement cards
Phone Site Editor, single post template
Sharing buttons section at phone width The Sharing Buttons and Like blocks after the post content in the Site Editor

Rationale

One side or the other. Core can't hook one block both before and after the post content (see #53413), and the route refuses a list with both sides. CheckboxCard is a checkbox, so the section makes the two cards a choice: every save sends the block's whole list ([], ['before_content'] or ['after_content']), and the copy says to pick one place. Radios would have no way to remove the block, which is why the cards stay checkboxes: unticking the ticked one is how it comes out.

One card for posts and pages. That's how the placements have worked since #53413. The heading says so, and the page template link covers owners who want something different on pages.

The preview link waits for the save. Before that, the template doesn't have the block yet. Newsletter does the same with isEnabledAndSaved. The settings store holds the optimistic value while a write is pending, so the link shows once nothing is saving. That also hides an already-saved card's link while another setting saves; in exchange, the store doesn't need a second copy of the settings.

No flash of the old button. "Switch to the … block" updates the status before settings are read again, so for a moment the section is in block_call_to_action without the key. The store counts the action as a pending write until that read lands, and the cards show disabled meanwhile. The Open Site Editor button now only shows when the server doesn't offer the key at all.

A refused save unticks the card again. The rollback only restores a setting while the store still holds the value that save wrote, compared by identity. Under TanStack Query the cache held a copy of every array, so list settings never rolled back. The store from #53853 keeps the array it's given, so they do again, and the rollback test now has a list row (show) next to the boolean one.

The "Pick one place" hint stays announced. A fieldset takes one description, and Fieldset.Details registers its own, so wherever the theme has a page template, screen readers heard "More details follow." instead of the hint. The notes under the cards are plain paragraphs.

It doesn't touch the PHP screen, which keeps its Open Site Editor link until it retires (CM-945), or the Jetpack dashboard and My Jetpack links.

Left for follow-ups:

  • The shared card has no disabled styling: while the cards are disabled, only the checkboxes fade. That would be a change to CheckboxCard itself, and would change Newsletter's cards too.
  • The cards can't tell when a template saved in the Site Editor has frozen the placement (core records the blocks as ignored once the template is saved), so ticking a card there still reports a save that changes nothing on that template. Fixing that needs status to say which templates are saved.
  • Two refused saves in a row, followed by a failed settings read, can roll a setting back to a value the first save never stored. That's in the store's saveSetting (data/writes.ts) and predates this PR.

The React screen is still behind rsm_jetpack_ui_modernization_sharing_likes, so the changelog entry is in the package only.

Related product discussion/links

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

No.

Testing instructions

On a connected Jetpack site running Twenty Twenty-Five, with the Sharing and Likes modules off and this in an mu-plugin:

add_filter( 'rsm_jetpack_ui_modernization_sharing_likes', '__return_true' );
  • Go to Settings > Sharing. The Sharing buttons and Like buttons sections each show two cards, "Before the content" and "After the content", with no Open Site Editor button.
  • In Sharing buttons, tick "Before the content". A "Settings have been saved" snackbar shows, then a "Preview and edit" link under the card. View a single post and a page: the Sharing Buttons block is above the content on both.
  • Tick "After the content". The first card unticks, and the block moves below the content on the post and the page.
  • Follow "Preview and edit": the Single Posts template shows the block after the Content block. Follow "Edit the page template": the Pages template has it too.
  • Do the same in Like buttons, with the Like block.
  • Untick the ticked card in each section. Both blocks are gone from the post and the page.
  • Resize the window below 720px: the cards stack in one column. Tab through them: each card shows a focus ring.
  • Tick "After the content" in Like buttons again, then turn the Sharing module on (wp jetpack module activate sharedaddy) and reload. The "Where sharing buttons appear" section shows up, and its description ends with "Blocks you add to your templates aren't affected." Untick Pages there: the legacy sharing buttons go away from pages, but the Like block stays.
  • Still with the Sharing module on, click "Switch to the Sharing Buttons block": the section goes straight to the cards, without showing the Open Site Editor button in between.

@jeherve jeherve added Enhancement Changes to an existing feature — removing, adding, or changing parts of it Docs [Status] Needs Review This PR is ready for review. [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests [Package] Sharing Likes labels Oct 20, 2026
@jeherve jeherve self-assigned this Oct 20, 2026
@github-actions

github-actions Bot commented Oct 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 add/sharing-likes-placement-cards branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/sharing-likes-placement-cards

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

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!

@jp-launch-control

jp-launch-control Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/sharing-likes/src/settings-app/sections/placement-section.tsx 7/8 (87.50%) 1.79% 0 💚

2 files are newly checked for coverage.

File Coverage
projects/packages/sharing-likes/src/settings-app/components/placement-illustrations.tsx 20/20 (100.00%) 💚
projects/packages/sharing-likes/src/settings-app/components/template-placements.tsx 20/20 (100.00%) 💚

Full summary · PHP report · JS report

@jeherve
jeherve marked this pull request as draft October 20, 2026 11:44
@jeherve

jeherve commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

Putting this on hold for a bit: we're moving the Settings > Sharing data layer off TanStack Query first, so this PR can use the new layer rather than reading TanStack's pending saves. I'll rebase once that lands.

…ards

Fixes CM-976

On block themes with the legacy buttons off, the Sharing buttons and
Like buttons sections only offered a link to the Site Editor, leaving
owners to find the right template and the right spot in it. CM-972
and CM-975 can now place each block before or after the content of
single posts and pages, so the sections offer that as two cards.

Core cannot hook one block on both sides of the content, and the
route refuses a list with both, so the cards are an either/or: each
change sends the whole list, ticking one card replaces the other, and
unticking the ticked one empties it. Saves go through useSaveSetting(),
so a refused save rolls the cards back.

"Preview and edit" only shows on a card the last save that went
through has ticked, since the template has no block before then. The
optimistic value is in the cache, so the saved one comes from the
oldest pending save's previous value.

"Switch to the … block" sets the new status before settings are read
again, so the variant briefly lacks the placement key. The cards show
disabled while a write or a settings read is in flight, and the old
button only stays for a server that does not offer the key.
Part of CM-976

The React screen's section in AGENTS.md covered the services manager
but not the cards that now replace the Site Editor link, nor when the
link still shows.
The rollback only restores a setting while the store still holds the
value that save wrote, compared by identity, so a later edit of the
same setting is kept. Under TanStack Query the cache held a copy of
every array, so no list setting ever rolled back: `show`, and the
template placements. The settings store keeps the value it is given,
so lists roll back again; this pins it with a list row next to the
boolean one.
… tests

`Fieldset.Root` holds one description id, and `Fieldset.Details`
registers its own, so wherever the theme has a page template, screen
readers lost "Pick one place: before or after the content." to the
hidden "More details follow." The notes under the cards are now plain
paragraphs, and the page template test asserts the fieldset's
description.

"Before the content" and "After the content" get translator context,
since they read as fragments on their own.

The tests drop rows and cases that no mutation of the component could
fail on their own (the rollback is covered in `use-save-setting`), and
the switch test now checks the fieldset by its legend and `aria-busy`.
Part of CM-976

The cards read two things from TanStack Query: whether settings were
still being re-read after "Switch to the … block", and the value of the
last save that went through, for the "Preview and edit" link. #53853
moved the screen to a @wordpress/data store, so both now come from its
pending-write count.

A feature action stays pending until settings are read again, so the
cards show disabled until the new variant's key arrives, as before.
While any write is pending, the stored settings may hold an optimistic
value, so the preview link waits until nothing is saving. That hides an
already-saved card's link for the length of another setting's save; in
exchange the cards need no copy of the last saved settings.
@jeherve
jeherve force-pushed the add/sharing-likes-placement-cards branch from 9b8faca to faeffea Compare October 21, 2026 12:45
Part of CM-976

The switch test only covers the moment when the key is missing and a
write is pending at once, so a component that disabled the cards and
marked the group busy during every placement save still passed. Users
would see the cards flicker disabled on each click. The preview test
now checks that the other card stays enabled while a save is pending.

The click table now has a Likes row, so the Likes setting key is tested
directly rather than only through the switch test. The comment above
the preview test went: the component holds that rationale, and the
test name already says it.
Part of CM-976

The note under the cards said saved templates "keep the blocks you left
in them, whatever you pick here", which reads as if a pick still
applies on top. It does not. Saving a template in the Site Editor
records each hooked block type in the anchor's `ignoredHookedBlocks`,
per type rather than per side. After that, a block the owner removed
stays removed, and moving a placement to the other side adds nothing
there.

The card's own "Preview and edit" link is the shortest way into that
state, so the note now says to move or remove those blocks in the Site
Editor.
Part of CM-976

AGENTS.md said each save "sends the whole list", which describes the
bug the tests guard against: the cards send one placement or none,
and that is why ticking one card unticks the other. It also left out
that the fallback waits while a write is pending, showing the cards
disabled instead.

The changelog entry read as if the live Settings > Sharing screen got
the cards. They are only in its React version, behind
`rsm_jetpack_ui_modernization_sharing_likes`, and the entry now says
so, matching the package's earlier entries for that screen.
@jeherve
jeherve marked this pull request as ready for review October 21, 2026 13:24
Part of CM-976

The "Where … appear" section stays on screen while another section
offers its block, and the block cards cover posts and pages whatever
that section says. Unticking Pages there reads as if it kept the
blocks off pages too. The section now says blocks added to templates
aren't affected, whenever a section offers its block.
@jeherve
jeherve merged commit cedd7a1 into trunk Oct 21, 2026
88 of 89 checks passed
@jeherve
jeherve deleted the add/sharing-likes-placement-cards branch October 21, 2026 15:36
@github-actions github-actions Bot removed [Status] In Progress [Status] Needs Review This PR is ready for review. labels Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Package] Sharing Likes [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant