-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Conversation
Size Change: +4.4 kB (0%) Total Size: 1.2 MB
ℹ️ View Unchanged
|
export default function LatestPostsEdit( { | ||
attributes, | ||
setAttributes, | ||
className, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me and it matches the frontend.
Thanks for the fix.
* nest content styles in container for higher specificity (#26487) * Reusable Blocks: Make the number retrieved from the API unlimited (#26486) * Make the number of reusable blocks returned from the API unlimited This is to fix #26352. Having no limit seems like it could be risky, but there are a number of other places in the codebase where all entities are returned in one call to the API, including categories, which could return a similar amount of data to this. * Remove unnecessary quotes to fix lint error. * Fix block inserter WSOD when an empty reusable block exists (#26484) * Latest Posts: Bring back classname on post list (#26477) * [Heading Block] Fix double alignment controls in toolbar (#26492) * fix heading alignments * add proper supports in deprecation * update all previous deprecations * regenerate fixtures for heading * change migration call * remove previous className + revert saves * Revert "regenerate fixtures for heading" This reverts commit 27af8c3. * change fixtures * create new fixtures + fix deprecation save * address review feedback * URLInput: Use debounce() instead of throttle() (#26529) Wait until the user finishes typing before sending an AJAX request. This ensures that there isn't an AJAX request sent every 200 ms while the user is typing. * Fix single column block display for smaller screens. (#26438) If there is only one column, don't force a 50% flex-basis for small screens. * Fix incorrectly pluralised strings (#26565) * Change block mover label i18n * Update remove block i18n * Ensure footer remains position fixed when navigating regions (#26533) * Update package-lock file to ensure static analysis task passes (#26528) * Removes extra fullstop (#26586) Co-authored-by: Addison Stavlo <Stavz01@gmail.com> Co-authored-by: Paul Bunkham <paul@dobit.co.uk> Co-authored-by: Noah Allen <noahtallen@gmail.com> Co-authored-by: Kelly Dwan <ryelle@users.noreply.github.com> Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com> Co-authored-by: Robert Anderson <robert@noisysocks.com> Co-authored-by: Aaron D. Campbell <aaron@AaronDCampbell.com> Co-authored-by: Daniel Richards <daniel.richards@automattic.com> Co-authored-by: Tammie Lister <tammie@automattic.com>
Description
Fixes #26445. In #26122 the Latest Posts edit component was refactored away from a class, which meant that the
this.props.className
was removed. This breaks latest posts styling, since themes rely on the.wp-block-latest-posts
class to style. This is most obvious when you try to switch to grid style.This PR simply adds the class back to the
ul
. I tried passing a props arg touseBlockProps
, but since the classname needs to be on theul
(not thediv
, whereuseBlockProps
is), this simple change works better.How has this been tested?
I tested with Twenty Twenty-One and Twenty Nineteen, both were broken (not showing posts in a grid, had bullet points) before this change.
Test by adding a Latest Posts block to your site, and making sure it looks the same on the frontend and editor.
Screenshots
These are both in the editor. Everything's fine on the frontend.
Before:
After:
Types of changes
Bug fix (non-breaking change which fixes an issue)