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

Latest Posts: Bring back classname on post list #26477

Merged
merged 4 commits into from
Oct 28, 2020
Merged
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ const USERS_LIST_QUERY = {
per_page: -1,
};

export default function LatestPostsEdit( { attributes, setAttributes } ) {
export default function LatestPostsEdit( {
attributes,
setAttributes,
className,
Copy link
Contributor

Choose a reason for hiding this comment

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

useBlockProps is supposed to apply automatically these custom and generated classNames, so I wonder if the issue here is more than the wrapping "div" should be removed and instead the block props applied to the ul

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, like I mentioned, I tried passing the className to useBlockProps so that it would work correctly, but the class belongs on the ul. I didn't think of removing the div, so I've tried that… it also didn't work initially, but clued me in to looking at other blocks, and finally it looks like the apiVersion was not updated in #26122, so the className is not being set correctly by useBlockProps.

With the fix for "apiVersion": 2 in the block.json, and moving blockProps to the <ul> , this seems to be working correctly now.

} ) {
const {
postsToShow,
order,
Expand Down Expand Up @@ -448,7 +452,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
<ToolbarGroup controls={ layoutControls } />
</BlockControls>
<ul
className={ classnames( {
className={ classnames( className, {
'wp-block-latest-posts__list': true,
'is-grid': postLayout === 'grid',
'has-dates': displayPostDate,
Expand Down