Skip to content

Commit db805a4

Browse files
authored
Latest Posts: Bring back classname on post list (#26477)
1 parent 1b74cd3 commit db805a4

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

packages/block-library/src/latest-posts/block.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"apiVersion": 2,
23
"name": "core/latest-posts",
34
"category": "widgets",
45
"attributes": {

packages/block-library/src/latest-posts/edit.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,15 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
400400
</InspectorControls>
401401
);
402402

403-
const blockProps = useBlockProps();
403+
const blockProps = useBlockProps( {
404+
className: classnames( {
405+
'wp-block-latest-posts__list': true,
406+
'is-grid': postLayout === 'grid',
407+
'has-dates': displayPostDate,
408+
'has-author': displayAuthor,
409+
[ `columns-${ columns }` ]: postLayout === 'grid',
410+
} ),
411+
} );
404412

405413
const hasPosts = Array.isArray( latestPosts ) && latestPosts.length;
406414
if ( ! hasPosts ) {
@@ -442,20 +450,12 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
442450
const dateFormat = __experimentalGetSettings().formats.date;
443451

444452
return (
445-
<div { ...blockProps }>
453+
<>
446454
{ inspectorControls }
447455
<BlockControls>
448456
<ToolbarGroup controls={ layoutControls } />
449457
</BlockControls>
450-
<ul
451-
className={ classnames( {
452-
'wp-block-latest-posts__list': true,
453-
'is-grid': postLayout === 'grid',
454-
'has-dates': displayPostDate,
455-
'has-author': displayAuthor,
456-
[ `columns-${ columns }` ]: postLayout === 'grid',
457-
} ) }
458-
>
458+
<ul { ...blockProps }>
459459
{ displayPosts.map( ( post, i ) => {
460460
const titleTrimmed = invoke( post, [
461461
'title',
@@ -585,6 +585,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
585585
);
586586
} ) }
587587
</ul>
588-
</div>
588+
</>
589589
);
590590
}

0 commit comments

Comments
 (0)