Question from #3111409: Add new Olivero frontend theme to Drupal 9.1 core as beta
Right now comments are hard-coded to appear at the bottom of the node:
core/themes/olivero/templates/content/node.html.twig
<div{{ content_attributes.addClass('node__content', layout) }}>
{# Comments not part of content, so they won't inherit .text-content styles. #}
{{ content|without('comment') }}
</div>
{% if content.comment %}
<div id="comments" class="{{ layout }}">
{{ content.comment }}
</div>
{% endif %}
It's not 100% clear why this is the case. Does that code comment mean that comments shouldn't inherit .text-content styles?
At the very least, this ensures that comments have a wrapper with the class of the layout, but there's other ways to do that.
But via Field UI you can position the comments (and any other field) into any order. If the comments are hard-coded in the markup above, that positioning is ignored.
Next steps
- Figure out what/why "so they won't inherit .text-content styles" means.
- Get a wrapper div around the comments in some other way.
Comments
Comment #2
mherchelComment #3
gauravvvv commentedI have attached a patch for the same. Please review.
Comment #4
gauravvvv commentedComment #5
vikashsoni commented@Gauravmahlawat i think u have to check this patch because it's repeating comment form twice and this is very confuse able
sharing the screenshot..
Comment #6
gauravvvv commentedComment #7
dalinComment #8
dalinComment #9
dalinRewrote the ticket description and title to better illustrate
Comment #10
gauravvvv commentedComment #11
tushar_sachdeva commentedComment #12
tushar_sachdeva commentedComment #13
aaron.ferris commentedWould something like this work? Ill confess im not sure I understand the reasons for the
{# Comments not part of content, so they won't inherit .text-content styles. #}either. Even with the template as it is, comments are inheriting.text-contentstyles so im slightly confused.Im not confident the patch is adequate, but it'd resolve the problem of comments not being positioned from the field_ui and gives the comment element a specific targetabble ID.
Main question I have is, is {{layout}} needed on the comment wrapper class if the parent element has a {{layout}} class?
Comment #14
aaron.ferris commentedLooking at the markup with the previous patch applied, I don't think we want the layout classes nested but im not 100%.
Comment #15
gauravvvv commentedComment #16
andy-blumAs noted in #3213214, we should also move the
id="comments"to the comments field template so it's still present when comments are displayed in a block via layout builder.Comment #17
xjmThis definitely a bug. It might be major. Promoting for visibility until we make that decision.
What happens when the comments are placed in a block with Layout Builder?
Comment #18
al0aAdded a new patch where the id 'comments' is set in the field template.
Comment #19
al0aComment #20
chetanbharambe commentedVerified and tested patch #18.
Patch applied successfully and looks good to me.
Testing Steps:
# Goto: Appearance -> Apply Olivero theme
# Goto: /admin/structure/types/manage/article/display
# Drag and drop the comment field at the top side or whatever you want.
# Create article content type
# Save it and check the results.
Expected Results:
# After applying the patch, the User is able to see placement of comments via field UI.
Actual Results:
# Currently, the Placement of comments via field UI is not working.
Please refer attached screenshots for the same.
Looks good to me.
Can be a move to RTBC.
Comment #21
alexpottWhy do we have the ID attribute here anyway? I'm not sure it is correct in either case. If we display two nodes on a page both with comments then we're going to get duplicate IDs. As far as I can see this ID is not at all necessary. Bartik's print style sheet claims that that theme uses #comments but it's not true. If you have comments there is no div with an ID of
comments. So why are we doing this in Olivero?