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

Comments Title: Count toggle working in 'Singular' editing mode (fix) #40728

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions packages/block-library/src/comments-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,15 @@ export default function Edit( {
? __( 'One response to ' )
: __( 'One response' );

const singlePlaceholderNoCount = showPostTitle
? __( 'Response to ' )
: __( 'Response' );

const multiplePlaceholder = showPostTitle
? __( 'responses to ' )
: __( 'responses' );

const multiplePlaceholderNoCount = showPostTitle
? __( 'Responses to ' )
: __( 'Responses' );

Expand All @@ -154,8 +162,16 @@ export default function Edit( {
<PlainText
__experimentalVersion={ 2 }
tagName="span"
aria-label={ singlePlaceholder }
placeholder={ singlePlaceholder }
aria-label={
showCommentsCount
? singlePlaceholder
: singlePlaceholderNoCount
}
placeholder={
showCommentsCount
? singlePlaceholder
: singlePlaceholderNoCount
}
value={ singleCommentLabel }
onChange={ ( newLabel ) =>
setAttributes( {
Expand All @@ -174,12 +190,12 @@ export default function Edit( {
aria-label={
showCommentsCount
? ` ${ multiplePlaceholder }`
: multiplePlaceholder
: multiplePlaceholderNoCount
}
placeholder={
showCommentsCount
? ` ${ multiplePlaceholder }`
: multiplePlaceholder
: multiplePlaceholderNoCount
}
value={ multipleCommentsLabel }
onChange={ ( newLabel ) =>
Expand Down
13 changes: 10 additions & 3 deletions packages/block-library/src/comments-title/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ function render_block_core_comments_title( $attributes ) {
return;
}

$single_default_comment_label = $show_post_title ? __( 'One response to' ) : __( 'One response' );
$single_comment_label = ! empty( $attributes['singleCommentLabel'] ) ? $attributes['singleCommentLabel'] : $single_default_comment_label;
$single_default_comment_label = $show_post_title ? __( 'Response to' ) : __( 'Response' );
if ( $show_comments_count ) {
$single_default_comment_label = $show_post_title ? __( 'One response to' ) : __( 'One response' );
}
$single_comment_label = ! empty( $attributes['singleCommentLabel'] ) ? $attributes['singleCommentLabel'] : $single_default_comment_label;

$multiple_default_comment_label = $show_post_title ? __( 'Responses to' ) : __( 'Responses' );
$multiple_comment_label = ! empty( $attributes['multipleCommentsLabel'] ) ? $attributes['multipleCommentsLabel'] : $multiple_default_comment_label;
if ( $show_comments_count ) {
$multiple_default_comment_label = $show_post_title ? __( 'responses to' ) : __( 'responses' );
}

$multiple_comment_label = ! empty( $attributes['multipleCommentsLabel'] ) ? $attributes['multipleCommentsLabel'] : $multiple_default_comment_label;

$comments_title = '%1$s %2$s %3$s';

Expand Down