Skip to content

Commit 6f7adc8

Browse files
carolinancbravobernal
authored andcommitted
Fix alignment issue with comment author name (#40610)
* Remove duplicate font size class * Update unit tests Co-authored-by: Carlos Bravo <carlos.bravo@automattic.com>
1 parent 01df2a5 commit 6f7adc8

File tree

2 files changed

+58
-6
lines changed

2 files changed

+58
-6
lines changed

packages/block-library/src/comment-author-name/index.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ function render_block_core_comment_author_name( $attributes, $content, $block )
2525

2626
$classes = '';
2727
if ( isset( $attributes['textAlign'] ) ) {
28-
$classes .= 'has-text-align-' . esc_attr( $attributes['textAlign'] );
29-
}
30-
if ( isset( $attributes['fontSize'] ) ) {
31-
$classes .= 'has-' . esc_attr( $attributes['fontSize'] ) . '-font-size';
28+
$classes .= 'has-text-align-' . $attributes['textAlign'];
3229
}
3330

3431
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );

phpunit/class-block-library-comment-template-test.php

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function test_rendering_comment_template() {
138138
// Here we use the function prefixed with 'gutenberg_*' because it's added
139139
// in the build step.
140140
$this->assertEquals(
141-
'<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>',
141+
'<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>',
142142
gutenberg_render_block_core_comment_template( null, null, $block )
143143
);
144144
}
@@ -186,11 +186,66 @@ function test_rendering_comment_template_nested() {
186186
)
187187
);
188188

189+
$top_level_ids = self::$comment_ids;
190+
$expected = str_replace(
191+
array( "\n", "\t" ),
192+
'',
193+
<<<END
194+
<ol >
195+
<li id="comment-{$top_level_ids[0]}" class="comment odd alt thread-odd thread-alt depth-1">
196+
<div class="wp-block-comment-author-name">
197+
<a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >
198+
Test
199+
</a>
200+
</div>
201+
<div class="wp-block-comment-content">
202+
Hello world
203+
</div>
204+
<ol>
205+
<li id="comment-{$first_level_ids[0]}" class="comment even depth-2">
206+
<div class="wp-block-comment-author-name">
207+
<a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >
208+
Test
209+
</a>
210+
</div>
211+
<div class="wp-block-comment-content">
212+
Hello world
213+
</div>
214+
<ol>
215+
<li id="comment-{$second_level_ids[0]}" class="comment odd alt depth-3">
216+
<div class="wp-block-comment-author-name">
217+
<a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >
218+
Test
219+
</a>
220+
</div>
221+
<div class="wp-block-comment-content">
222+
Hello world
223+
</div>
224+
</li>
225+
</ol>
226+
</li>
227+
<li id="comment-{$first_level_ids[1]}" class="comment even depth-2">
228+
<div class="wp-block-comment-author-name">
229+
<a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >
230+
Test
231+
</a>
232+
</div>
233+
<div class="wp-block-comment-content">
234+
Hello world
235+
</div>
236+
</li>
237+
</ol>
238+
</li>
239+
</ol>
240+
END
241+
);
242+
189243
$this->assertEquals(
190244
gutenberg_render_block_core_comment_template( null, null, $block ),
191-
'<ol ><li id="comment-' . self::$comment_ids[0] . '" class="comment odd alt thread-odd thread-alt 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><ol><li id="comment-' . $first_level_ids[0] . '" class="comment even depth-2"><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><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"><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></li></ol></li></ol>'
245+
$expected
192246
);
193247
}
248+
194249
/**
195250
* Test that both "Older Comments" and "Newer Comments" are displayed in the correct order
196251
* inside the Comment Query Loop when we enable pagination on Discussion Settings.

0 commit comments

Comments
 (0)