fix(block-theme): load block styles when needed#4555
Conversation
There was a problem hiding this comment.
Pull request overview
Updates frontend asset loading for Newspack blocks so dist/blocks.css is enqueued when a post/page actually contains Newspack block markup (fixing missing frontend styling like Social Links bullets when using Author Profile blocks).
Changes:
- Refines
Blocks::should_load_block_assets()to load styles on Collections archives/singles. - Adds a singular-page content check intended to detect whether any Newspack block is present before enqueuing
blocks.css.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
miguelpeixe
left a comment
There was a problem hiding this comment.
The logic for the should_load_block_assets() method follows (both in trunk and in your PR), but even when returning false (trunk), blocks.css was loading in the frontend for me.
I tried commenting out this bit, but nothing changed:
Then I learned it was this:
WP will automatically enqueue assets declared in the block.json file if the page renders it. So it's possible that in your tests, you always had the My Account button block rendering and enqueueing the CSS.
|
Ohhhh thanks @miguelpeixe! That makes sense -- I have had that block active most of the time 🤦♀️ So glad I'm not completely losing it! 🎉 |
|
Hey @laurelfulford, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
# [6.36.0-alpha.1](v6.35.1...v6.36.0-alpha.1) (2026-03-19) ### Bug Fixes * **access-rules:** normalize rules to individual OR groups ([#4584](#4584)) ([40a7259](40a7259)) * apply max-width to add payment method iframe ([#4575](#4575)) ([de27bb5](de27bb5)) * **block-theme:** ensure content gate contents inserted in time for styles to be rendered ([#4539](#4539)) ([2be2f3b](2be2f3b)) * **block-theme:** load block styles when needed ([#4555](#4555)) ([ec4c70b](ec4c70b)) * **block-theme:** migrate newspack-theme modal checkout fixes ([#4557](#4557)) ([6eb5f48](6eb5f48)) * **content-gating:** allow for metering with paid access only ([#4571](#4571)) ([e2d8e01](e2d8e01)) * exclude Jetpack Swiper CSS from perfmatters unused CSS feature ([#4538](#4538)) ([0d64190](0d64190)) * guard against null, but enumerated, storage keys ([adcec53](adcec53)) * **integrations:** integrations settings registration ([#4573](#4573)) ([a4d90c2](a4d90c2)) * json_decode and notice style fixes ([#4531](#4531)) ([8fc6ada](8fc6ada)) * use correct is_enabled method ([#4564](#4564)) ([6396e41](6396e41)), closes [#4541](#4541) ### Features * **alert-manager:** failure pattern detection ([#4527](#4527)) ([9a0bb3d](9a0bb3d)) * alerting system ([#4511](#4511)) ([1df65a0](1df65a0)) * **content-gate:** default block patterns ([#4540](#4540)) ([4852a9a](4852a9a)) * **content-gate:** display matching gates in post editor ([#4572](#4572)) ([eb275eb](eb275eb)) * **content-gating:** group subscriptions members in my account ([#4543](#4543)) ([202781a](202781a)) * **content-gating:** i3 designs for Metered Countdown + Content Gifting ([#4526](#4526)) ([ba5b4ee](ba5b4ee)) * **group-subscription:** invite email and acceptance flow ([#4546](#4546)) ([ac50a98](ac50a98)) * **integrations:** add integrations settings framework ([#4541](#4541)) ([735e640](735e640)) * **integrations:** refactor metadata for integration specific selection ([#4544](#4544)) ([eb747fc](eb747fc)) * new `getAll()` method to fetch all reader data from store at once ([fbe68db](fbe68db)) * new `getAll()` method to retrieve all items from the reader data store ([b7d6664](b7d6664)) * **reader-activation:** add integration health check system ([#4550](#4550)) ([4993f21](4993f21)) * **yoast:** add Bluesky contact method registration ([#4554](#4554)) ([aa143d7](aa143d7))
|
🎉 This PR is included in version 6.36.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
# [6.36.0](v6.35.2...v6.36.0) (2026-03-30) ### Bug Fixes * **access-rules:** normalize rules to individual OR groups ([#4584](#4584)) ([40a7259](40a7259)) * apply max-width to add payment method iframe ([#4575](#4575)) ([de27bb5](de27bb5)) * **block-theme:** ensure content gate contents inserted in time for styles to be rendered ([#4539](#4539)) ([2be2f3b](2be2f3b)) * **block-theme:** load block styles when needed ([#4555](#4555)) ([ec4c70b](ec4c70b)) * **block-theme:** migrate newspack-theme modal checkout fixes ([#4557](#4557)) ([6eb5f48](6eb5f48)) * **content-gating:** allow for metering with paid access only ([#4571](#4571)) ([e2d8e01](e2d8e01)) * exclude Jetpack Swiper CSS from perfmatters unused CSS feature ([#4538](#4538)) ([0d64190](0d64190)) * guard against null, but enumerated, storage keys ([adcec53](adcec53)) * **integrations:** integrations settings registration ([#4573](#4573)) ([a4d90c2](a4d90c2)) * json_decode and notice style fixes ([#4531](#4531)) ([8fc6ada](8fc6ada)) * use correct is_enabled method ([#4564](#4564)) ([6396e41](6396e41)), closes [#4541](#4541) ### Features * **alert-manager:** failure pattern detection ([#4527](#4527)) ([9a0bb3d](9a0bb3d)) * alerting system ([#4511](#4511)) ([1df65a0](1df65a0)) * **content-gate:** default block patterns ([#4540](#4540)) ([4852a9a](4852a9a)) * **content-gate:** display matching gates in post editor ([#4572](#4572)) ([eb275eb](eb275eb)) * **content-gating:** group subscriptions members in my account ([#4543](#4543)) ([202781a](202781a)) * **content-gating:** i3 designs for Metered Countdown + Content Gifting ([#4526](#4526)) ([ba5b4ee](ba5b4ee)) * **group-subscription:** invite email and acceptance flow ([#4546](#4546)) ([ac50a98](ac50a98)) * **integrations:** add integrations settings framework ([#4541](#4541)) ([735e640](735e640)) * **integrations:** refactor metadata for integration specific selection ([#4544](#4544)) ([eb747fc](eb747fc)) * new `getAll()` method to fetch all reader data from store at once ([fbe68db](fbe68db)) * new `getAll()` method to retrieve all items from the reader data store ([b7d6664](b7d6664)) * **reader-activation:** add integration health check system ([#4550](#4550)) ([4993f21](4993f21)) * **yoast:** add Bluesky contact method registration ([#4554](#4554)) ([aa143d7](aa143d7))
|
🎉 This PR is included in version 6.36.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
This PR fixes a weird issue that seems to have started happening after I wiped my test site: blocks like the social links block from the Author Profile block aren't loading CSS on the front-end.
Looking at the code I think this makes sense -- it's checking to see if we're on a Collections page before loading. What I don't get is how it worked for me in the first place. I'm not sure if my test site was in a weird state before (like had a Collections block in the template), or is somehow in a weird state now. I did have a pretty mangled template, so it could be the former, but I wish I could get it back to check.
This PR adds a check for blocks in the content as well. I'm open to other approaches, too, if there's a better way - maybe removing the check entirely?
Also I'd be interested if this is working for anyone else? I'm so confused 😂
Closes NPPD-1348
How to test the changes in this Pull Request:
Other information: