-
Notifications
You must be signed in to change notification settings - Fork 14
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
CoreListItem return sublist html in attributes.content #253
Comments
Hey @MKlblangenois. Looking at the core/list-item block.json spec it looks like this is the expected behavior. The content attribute for this is located here: https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/list-item/block.json
the selector targets a single |
@MKlblangenois @theodesp I have 2 thoughts on this. My first thought was: Any field that returns HTML should return valid HTML. i.e. this field should return the HTML and include the opening and closing Since this field returns invalid HTML, it requires the user to wrap the field in an However, the (pseudo) switch ( block.__typename ) {
case: 'core/list-item':
return <li>{block.attributes.content}</li>
} I think long-term it would be nice to see fields that return HTML return valid HTML though. If core WPGraphQL were to introduce an HTML Scalar, this field would fail validation as-is, for example. |
I can confirm that this is still happening as of
and
if accroding to @theodesp
returned graphQL block object is: {
"__typename": "CoreList",
"id": "676175143efb3",
"name": "core/list",
"parentId": null,
"renderedHtml": "<ul class=\"wp-block-list\">\n<li>list item 1</li>\n\n\n\n<li>list item 2\n<ul class=\"wp-block-list\">\n<li>list item 2 nested item</li>\n</ul>\n</li>\n</ul>\n",
"attributes": {
"anchor": null,
"backgroundColor": null,
"className": null,
"fontFamily": null,
"fontSize": null,
"gradient": null,
"lock": null,
"ordered": false,
"reversed": null,
"start": null,
"style": null,
"textColor": null,
"type": null,
"values": "<li>list item 1</li><li>list item 2\n<ul class=\"wp-block-list\">\n<li>list item 2 nested item</li>\n</ul>\n</li><li>list item 2 nested item</li><li>list item 2 nested item</li>",
"cssClassName": "wp-block-list"
}
} causing that list rendered on the FE is instead of the expected nested list looking like:
Should GraphQL blocks plugin deals with core/list-item block in different way and provide already proper HTML markup so it can be parsed by the Faust application on the front end or should that be dealt with on the FE? How to solve it and where would be the best to solve it, is probably the question for @jasonbahl and/or @theodesp. Thank you in advance for any progress on this one. Note: Current workaround for this issue is to created custom |
The real answer is that the frontend Take a look at the respective |
When I create a list with sublist inside
<li>
, the query inattributes.content
of parent<li>
return all HTML content, and duplicate the content at the end of content:�
The text was updated successfully, but these errors were encountered: