Skip to content

Commit

Permalink
Fix alignment issue with comment author name (#40610)
Browse files Browse the repository at this point in the history
* Remove duplicate font size class

* Update unit tests

Co-authored-by: Carlos Bravo <carlos.bravo@automattic.com>
  • Loading branch information
carolinan and cbravobernal authored Apr 26, 2022
1 parent 7f0c753 commit 2d62d1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 1 addition & 4 deletions packages/block-library/src/comment-author-name/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ function render_block_core_comment_author_name( $attributes, $content, $block )

$classes = '';
if ( isset( $attributes['textAlign'] ) ) {
$classes .= 'has-text-align-' . esc_attr( $attributes['textAlign'] );
}
if ( isset( $attributes['fontSize'] ) ) {
$classes .= 'has-' . esc_attr( $attributes['fontSize'] ) . '-font-size';
$classes .= 'has-text-align-' . $attributes['textAlign'];
}

$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
Expand Down
10 changes: 5 additions & 5 deletions phpunit/class-block-library-comment-template-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function test_rendering_comment_template() {
// Here we use the function prefixed with 'gutenberg_*' because it's added
// in the build step.
$this->assertEquals(
'<ol ><li id="comment-' . self::$comment_ids[0] . '" class="comment even thread-even depth-1"><div class="has-small-font-size wp-block-comment-author-name"><a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >Test</a></div><div class="wp-block-comment-content">Hello world</div></li></ol>',
'<ol ><li id="comment-' . self::$comment_ids[0] . '" class="comment even thread-even depth-1"><div class="wp-block-comment-author-name"><a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >Test</a></div><div class="wp-block-comment-content">Hello world</div></li></ol>',
gutenberg_render_block_core_comment_template( null, null, $block )
);
}
Expand Down Expand Up @@ -194,7 +194,7 @@ function test_rendering_comment_template_nested() {
<<<END
<ol >
<li id="comment-{$top_level_ids[0]}" class="comment odd alt thread-odd thread-alt depth-1">
<div class="has-small-font-size wp-block-comment-author-name">
<div class="wp-block-comment-author-name">
<a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >
Test
</a>
Expand All @@ -204,7 +204,7 @@ function test_rendering_comment_template_nested() {
</div>
<ol>
<li id="comment-{$first_level_ids[0]}" class="comment even depth-2">
<div class="has-small-font-size wp-block-comment-author-name">
<div class="wp-block-comment-author-name">
<a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >
Test
</a>
Expand All @@ -214,7 +214,7 @@ function test_rendering_comment_template_nested() {
</div>
<ol>
<li id="comment-{$second_level_ids[0]}" class="comment odd alt depth-3">
<div class="has-small-font-size wp-block-comment-author-name">
<div class="wp-block-comment-author-name">
<a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >
Test
</a>
Expand All @@ -226,7 +226,7 @@ function test_rendering_comment_template_nested() {
</ol>
</li>
<li id="comment-{$first_level_ids[1]}" class="comment even depth-2">
<div class="has-small-font-size wp-block-comment-author-name">
<div class="wp-block-comment-author-name">
<a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >
Test
</a>
Expand Down

0 comments on commit 2d62d1c

Please sign in to comment.