fix: make sure we get block-supports styles for the overlay gates in time#4449
Open
laurelfulford wants to merge 6 commits intotrunkfrom
Open
fix: make sure we get block-supports styles for the overlay gates in time#4449laurelfulford wants to merge 6 commits intotrunkfrom
laurelfulford wants to merge 6 commits intotrunkfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a styling issue with overlay content gates when using block themes. The core problem is that block-specific styles (alignments, spacing, etc.) were not being generated for the gate content because it was injected too late in the page rendering process via wp_footer.
Changes:
- Extracted gate layout validation logic into a reusable private method
get_overlay_gate_layout_id() - Added
prepare_overlay_gate_styles()method that pre-renders gate content duringwp_enqueue_scriptsto trigger block style generation - Registered and enqueued gate-specific block support styles as inline CSS early in the page head
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
I need to look at this again with fresh eyes (long day!) but I think I may be getting this issue with the Classic theme, too 😕 |
Contributor
Author
|
I can also see the issue on a JN site running the classic theme, so I've removed the block theme check and updated the testing steps. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
Edited I originally thought this was a block theme issue but I can recreate it on a fresh site running the Classic Theme, too. I've updated the details testing steps accordingly!
Right now, the overlay content gate is getting inserted at
wp_footer.When a block theme is usedCertain block styles are generated as needed by WordPress, and they're not automatically availablelike they are with the classic theme. By the time the inline gate is injected, it's "too late" for its blocks to be included in those inline styles. This means certain styles -- like block alignments and spacing -- don't work in the gates.This PR renders the gate's content early so it can get all the styles that are needed, and adds them in their own inline styles separate from the WordPress ones.
I'm not sure if this is the best approach. The other solution I tried was rendering the overlay earlier. That also seemed to work, but it seems more dependent on how the theme is structured, and it would involve a bit of a rewrite of the overlay styles so they'd still work. It seemed a little messier, and possibly more likely to introduce issues, so just sticking to this for now. Open to feedback on the approach though!
Closes NPPD-1181
How to test the changes in this Pull Request:
npm run build.newspack-content-gate-block-supports(the styles injected for the overlay block) andcore-block-supports-inline-css. Do a bit of spot checking (mostly making sure the former isn't huge) to confirm that thenewspack-content-gate-block-supportsstyles aren't repeating a bunch of stuff fromcore-block-supports-inline-css.Other information: