Skip to content

Commit

Permalink
Query Total: Remove nested element (#68304)
Browse files Browse the repository at this point in the history
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: fabiankaegy <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
  • Loading branch information
4 people authored Dec 26, 2024
1 parent 261979a commit 10ada5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
24 changes: 11 additions & 13 deletions packages/block-library/src/query-total/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,25 @@ export default function QueryTotalEdit( { attributes, setAttributes } ) {

// Controls for the block.
const controls = (
<>
<BlockControls>
<ToolbarGroup>
<ToolbarDropdownMenu
icon={ getButtonPositionIcon() }
label={ __( 'Change display type' ) }
controls={ buttonPositionControls }
/>
</ToolbarGroup>
</BlockControls>
</>
<BlockControls>
<ToolbarGroup>
<ToolbarDropdownMenu
icon={ getButtonPositionIcon() }
label={ __( 'Change display type' ) }
controls={ buttonPositionControls }
/>
</ToolbarGroup>
</BlockControls>
);

// Render output based on the selected display type.
const renderDisplay = () => {
if ( displayType === 'total-results' ) {
return <div>{ __( '12 results found' ) }</div>;
return <>{ __( '12 results found' ) }</>;
}

if ( displayType === 'range-display' ) {
return <div>{ __( 'Displaying 1 – 10 of 12' ) }</div>;
return <>{ __( 'Displaying 1 – 10 of 12' ) }</>;
}

return null;
Expand Down
11 changes: 3 additions & 8 deletions packages/block-library/src/query-total/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ function render_block_core_query_total( $attributes, $content, $block ) {
switch ( $attributes['displayType'] ) {
case 'range-display':
if ( $start === $end ) {
$range_text = sprintf(
$output = sprintf(
/* translators: 1: Start index of posts, 2: Total number of posts */
__( 'Displaying %1$s of %2$s' ),
$start,
$max_rows
);
} else {
$range_text = sprintf(
$output = sprintf(
/* translators: 1: Start index of posts, 2: End index of posts, 3: Total number of posts */
__( 'Displaying %1$s – %2$s of %3$s' ),
$start,
Expand All @@ -56,17 +56,12 @@ function render_block_core_query_total( $attributes, $content, $block ) {
);
}

$output = sprintf( '<p>%s</p>', $range_text );
break;

case 'total-results':
default:
// translators: %d: number of results.
$total_text = sprintf( _n( '%d result found', '%d results found', $max_rows ), $max_rows );
$output = sprintf(
'<p>%s</p>',
$total_text
);
$output = sprintf( _n( '%d result found', '%d results found', $max_rows ), $max_rows );
break;
}

Expand Down

1 comment on commit 10ada5a

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 10ada5a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12500599529
📝 Reported issues:

Please sign in to comment.