-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Social Link: Add contentOnly editing support #66622
Social Link: Add contentOnly editing support #66622
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +212 B (+0.01%) Total Size: 1.81 MB
ℹ️ View Unchanged
|
Flaky tests detected in bdd8687. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11601729247
|
}, | ||
"service": { | ||
"type": "string" | ||
}, | ||
"label": { | ||
"type": "string" | ||
"type": "string", | ||
"role": "content" | ||
}, | ||
"rel": { | ||
"type": "string" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the button block has rel
as role: content
, but the image block doesn't, which is a bit of a quandry. I think it maybe makes sense for it to have a content
role, as it's part of the url which is also content. If the user can edit a url, they may want to also set rel
and openInNewTab
, so those have to be contentOnly
too.
On the social link block, the rel can't be edited in contentOnly mode (it's in the inspector > advanced area), so perhaps it should be a follow-up issue to make that work in addition to adding the role.
@@ -141,6 +146,41 @@ const SocialLinkEdit = ( { | |||
|
|||
return ( | |||
<> | |||
{ isContentOnlyMode && showLabels && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using the block normally (not in contentOnly), it's possible to always edit the text in the inspector, and the text is used for screen readers, so I wonder if it's worth considering making it always show in content only mode too. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<TextControl | ||
__next40pxDefaultSize | ||
__nextHasNoMarginBottom | ||
className="wp-block-social-link__toolbar_content_text" | ||
label={ __( 'Text' ) } | ||
help={ __( | ||
'Provide a text label or use the default.' | ||
) } | ||
value={ label } | ||
onChange={ ( value ) => | ||
setAttributes( { label: value } ) | ||
} | ||
placeholder={ socialLinkName } | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider it out of scope for this PR, but in usage it feels like the text should be editable inline (as RichText) when showLabels is active.
It probably becomes more obvious in contentOnly mode. Maybe there are reasons it wasn't done like that 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works well and code looks good. The comments are mostly subjective, but I'd be curious for your thoughts on them.
For some things, it might be good to get design feedback, like the 'Text' dropdown on the toolbar when in contentOnly mode (I left a comment about whether it should always be shown).
@richtabor is usually interested in these things 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw this one again. Let's merge this, the comments can be addressed in follow-ups if needed.
Co-authored-by: ndiego <[email protected]> Co-authored-by: talldan <[email protected]>
What?
This PR adds
contentOnly
editing support for the Social Link block, similar to the way we currently handle the editing mode in the Image block.Why?
When content only editing is enabled via
"templateLock": "contentOnly"
any Social Link blocks within the container cannot be edited by the user. There are scenarios where the user should be able to at least edit theurl
andlabel
attributes, especially when the block is distributed in a pattern that can be used in a variety of contexts.How?
This PR sets
"role": "content"
on theurl
andlabel
attributes inblock.json
. Doing so automatically enables the<URLPopover>
component, so nothing more is needed for editing the icon URL.The icon Text, on the other hand, is only editable in the block inspector, which is completely disabled in
contentOnly
mode. Therefore, this PR applies the same approach used in the Image block, where a button/popover is added to the block toolbar that allows the user to edit thelabel
attribute. This "Text" button is conditional based on whether "Show text" has been enabled on the parent Social Links block.Testing Instructions
Screenshots or screencast
contentOnly
support)