Repository navigation
Sharing & Likes: Make the template placements one radio choice, with "Don't add it" first - #54212
Merged
Merged
Conversation
Part of CM-998 The Sharing & Likes screen uses CheckboxCard for its template placements, but a block goes on one side of the post content at most, so the two cards were a single choice drawn as two checkboxes. Screen readers announced independent checkboxes, and ticking one unticked the other. The screen needs the same card with a radio in it. RadioCard has the CheckboxCard props minus `checked` and `onChange`: the surrounding RadioGroup owns the value, and the card gives it its `value`. It needs a Field.Root around that group, as the Field.Item it renders requires one. The card shows as selected through the radio's `data-checked` attribute, so it needs no prop for that either. The grid, card, illustration and control rules move to mixins in selectable-card/_selectable-card.scss, shared by both cards. CheckboxCard compiles to the same CSS as before.
Part of CM-998 The cards placing the Sharing Buttons and Like blocks were checkboxes that unticked each other, since core only hooks a block on one side of the post content. A tester on the call for testing asked whether they should be radio buttons, as you can only pick one. They should: the choice has three answers, before the content, after it, or neither. The checkboxes needed a "Pick one place" hint to explain that, and screen readers still announced two independent controls. Each section now renders one radio group: "Don't add it automatically" first, the state a site starts in after switching to the blocks, then a RadioCard per side. The legend is a question those three answers fit, and the hint goes. Picking a card still saves a one-item list and the first option an empty one, so the route never sees both sides. While settings catch up after "Switch to the … block", the whole group shows disabled, as the cards did.
Contributor
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Contributor
|
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! |
Code Coverage SummaryCoverage changed in 1 file.
2 files are newly checked for coverage.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes CM-998
Proposed changes
On block themes, the Sharing buttons and Like buttons sections of the React Settings > Sharing screen offer two cards that add the section's block before or after the post content. The cards are checkboxes, but you can only pick one: ticking one unticks the other, and a "Pick one place: before or after the content." hint is there to explain it. During the call for testing, one of the testers asked whether they should be radio buttons. They should :)
Each section is now one radio group with three choices:
The legend is now a question those three choices answer, "Where should the Sharing Buttons block go on posts and pages?" (or the Like block), and the hint is gone.
The cards are a new
RadioCardin@automattic/jetpack-components, next toCheckboxCard. The two share their styles throughselectable-card/_selectable-card.scss.CheckboxCardcompiles to the same CSS as before, so Newsletter's cards don't change.Rationale
Three answers, so a radio group. #53838 kept the cards as checkboxes because two radios would have had no way to take the block out again; unticking the ticked card was how it came out. A third option covers that. Screen readers announced two independent checkboxes for what is one choice; they now announce one radio group, named by the question, with three options.
"Don't add it automatically" comes first. It's the default, so the group reads in order: no, before, after. The arrow keys move in that order too. I considered drawing it as a third card, but a wireframe of a post with nothing added doesn't say much next to the other two, and three cards don't fit the two-column grid. As a plain radio, it leaves the cards as the obvious thing to pick.
Same saves as before. Picking a card sends
['before_content']or['after_content'], and the first option sends[], through the sameuseSaveSetting(), so the route still never sees both sides. While settings catch up after "Switch to the … block", the whole group shows disabled, as the cards did.Of note, radio groups select as you arrow through them, so going from "Don't add it automatically" to "After the content" with the keyboard saves twice. The write queue sends both in order, and the last one wins.
It doesn't touch the PHP screen, or the cards' disabled styling: while the group is disabled, only the radios fade, as the checkboxes did. Changing that would also change Newsletter's cards.
The React screen is still behind
rsm_jetpack_ui_modernization_sharing_likes, so the changelog entries are in the packages only.Related product discussion/links
CheckboxCard, whichRadioCardsits next toDoes this pull request change what data or activity we track or use?
No.
Testing instructions
On a connected Jetpack site running a block theme (Twenty Twenty-Four or Twenty Twenty-Five), with the Sharing and Likes modules on and this in an mu-plugin: