Skip to content
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

Comment template: Call comment_class() before recursing into child comments #40455

Merged
merged 5 commits into from
Apr 20, 2022

Conversation

michalczaplinski
Copy link
Contributor

@michalczaplinski michalczaplinski commented Apr 20, 2022

What?

The odd and even CSS classes were not being applied correctly to the comments in the Comment Template.

I've moved the call to comment_class() to BEFORE we recurse into the children so that it's in line with how comments are being rendered in the WordPress core.

Screenshots

I've added this CSS so that you can see the difference:

.even { 
  background-color: aquamarine;
}

.odd {
  background-color: lightblue;
}

This is what the core comments look like. The colors alternate, regardless of the comment level:

Screenshot 2022-04-19 at 20 11 09

Before (left) and after (right)

Comments rendered with the Comments Query Loop:

Screenshot 2022-04-19 at 20 10 59 Screenshot 2022-04-19 at 20 10 05

@michalczaplinski michalczaplinski added [Type] Bug An existing feature does not function as intended [Block] Comment Template Affects the Comment Template Block labels Apr 20, 2022
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a small suggestion (non-blocking); otherwise, this looks good to me 👍

Thanks, @michalczaplinski.

@ockham
Copy link
Contributor

ockham commented Apr 20, 2022

Great catch @michalczaplinski! And thanks @Mamaduka for your review!

Going to merge once we go green 🙂

@ockham
Copy link
Contributor

ockham commented Apr 20, 2022

Oh, one more note, maybe we can add (or extend) a unit test in phpunit/class-block-library-comment-template-test.php to cover this behavior 🤔 I'll have a quick look.

@ockham
Copy link
Contributor

ockham commented Apr 20, 2022

Oh, one more note, maybe we can add (or extend) a unit test in phpunit/class-block-library-comment-template-test.php to cover this behavior 🤔 I'll have a quick look.

(I'll keep that for a follow-up.)

@ockham ockham merged commit caf7b7d into trunk Apr 20, 2022
@ockham ockham deleted the fix/comment-class-missing-classes branch April 20, 2022 12:03
@github-actions github-actions bot added this to the Gutenberg 13.1 milestone Apr 20, 2022
@ockham ockham added the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Apr 20, 2022
ockham added a commit that referenced this pull request Apr 22, 2022
ockham added a commit that referenced this pull request Apr 25, 2022
…sing into child comments (#40455)""

This reverts commit 922abd3.
gziolo pushed a commit that referenced this pull request Apr 25, 2022
@gziolo
Copy link
Member

gziolo commented Apr 25, 2022

Cherry-picked to the wp/6.0 branch for WordPress Beta 3 release.

@gziolo gziolo removed the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Comment Template Affects the Comment Template Block [Type] Bug An existing feature does not function as intended
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants