Repository navigation
fix: restore legacy Latest Posts grid columns - #85258
KhushalSainS wants to merge 1 commit into
Conversation
🤖 PR meta 🤖👋 Welcome👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @KhushalSainS! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. 🎉 PropsUnlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @reidab. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the 🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
What?
Closes #85242
Restores the legacy default column count for Latest Posts blocks saved before the layout-support migration. Legacy grid content such as:
<!-- wp:latest-posts {"postLayout":"grid"} /-->now renders
columns-3again, so the front end displays a three-column grid instead of a single stacked column.Why?
#77989 moved Latest Posts to layout support and removed
postLayoutandcolumnsfromblock.json. The oldcolumnsattribute had"default": 3, so grid blocks that used the default column count were saved with only"postLayout":"grid", with nocolumnskey.Before 7.1, block registration supplied
columns => 3, and the render callback outputcolumns-3. That default no longer exists, and the server fallback now resolves tonull:The editor still falls back to 3 in
edit.jsxand in the block deprecation, so editors see a three-column grid while the front end renders one column. Server rendering does not run editor deprecations, and saving a post without editing the block does not migrate the stored attributes.How?
Restore the legacy default only when no
layoutattribute exists:This keeps the following behavior unchanged:
columnsvalue keep that value.layout.columnCountbehavior, including grids that intentionally omitcolumnCount.No content migration or re-save is required; the fallback happens at render time. Added PHPUnit regression coverage for the legacy default, explicit column counts, list layout, migrated layout content, and modern layout grids.
Screenshots or screencast
Use of AI Tools
AI assistance: Yes
Tool(s): OpenAI Codex
Used for: Reproducing the regression, checking the WordPress 7.0.4 and 7.1.3 render paths, drafting the PHP fix and PHPUnit regression tests, and drafting this PR description. I have reviewed and manually tested the code.