-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Fix example code #6787
Fix example code #6787
Conversation
tagName missing
Hi @ajitbohra thank you for your contribution. |
@jorgefilipecosta the tagname is defined in the edit method as This is an error in the docs regardless of if there is also a bug in the RichText component. But don't worry, @danielbachhuber closed the issue without resolving it. |
Have checked rich text docs you are right tagName is optional. If I am not wrong in the context of block edit/save we need to specify tagName so that it matches with the attributes schema. The example in docs needs "p" to properly get & save the data. In rich text docs, we have tagName specified for both edit & save. const { registerBlockType } = wp.blocks;
const { RichText } = wp.editor;
registerBlockType( /* ... */, {
// ...
attributes: {
content: {
type: 'array',
source: 'children',
selector: 'h2',
},
},
edit( { className, attributes, setAttributes } ) {
return (
<RichText
tagName="h2"
className={ className }
value={ attributes.content }
onChange={ ( content ) => setAttributes( { content } ) }
/>
);
},
save( { attributes } ) {
return <RichText.Content tagName="h2" value={ attributes.content } />;
}
} ); |
It's intended that without tagName, it shouldn't render a wrapper. I know it does for the I agree the docs should be updated. |
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.
LGTM 👍
Thank you for clarifying this @youknowriad.
You are right @NathanDJohnson thank you for referring this, I missed this check on the difference between edit and save. When comparing against RichText documentation I thought we might have a bug there. |
@jorgefilipecosta we were in the same boat :) thanks to @youknowriad for clarification |
tagName missing
fixes #6763
Description
Docs Update
Types of changes
Docs update
Checklist: