Skip to content

fix: prevent content-gate editor.scss styles from getting chunked into the common.css file#4716

Merged
laurelfulford merged 6 commits into
releasefrom
fix/remove-component-margins
Jun 2, 2026
Merged

fix: prevent content-gate editor.scss styles from getting chunked into the common.css file#4716
laurelfulford merged 6 commits into
releasefrom
fix/remove-component-margins

Conversation

@laurelfulford
Copy link
Copy Markdown
Contributor

@laurelfulford laurelfulford commented May 11, 2026

All Submissions:

Changes proposed in this Pull Request:

This one was weird!

In #4646, a new file block-visibility.tsx started importing content-gate/editor.scss. Newspack Plugin's Webpack has minChunks: 2; since this was the second file editor.css was imported into, it started getting included in the common.css, which caused the .components-base-control styles in that CSS file to bleed into more post types.

The .components-base-control style wasn't very specific, but this only started being an issue when the styles were imported into more editors.

This PR does two things:

  1. It moves the styles block-visiblity.tsx needed into its own CSS file, so editor.scss isn't being imported twice, and isn't getting added to the common.scss.
  2. It makes the .components-base-control styles more specific (adding content gate-specific CSS classes) since this issue was still happening when you edited a Content Gate.

Closes NPPM-2812

How to test the changes in this Pull Request:

  1. On trunk, edit a post and click the publish date in the sidebar; note the appearance of the date picker.
  2. Apply this PR and run npm run build; refresh the post editor and confirm the date picker looks okay.
  3. Using Woo Memberships, set up a Content Gate and confirm the same date picker looks okay.
  4. Set up access control (add define( 'NEWSPACK_CONTENT_GATES', true ); to your wp-config.php, and set up a content gate).
  5. Edit a post, and add a group block. Confirm the options in the 'Access Control' panel look okay.
  6. Smoke test some of the other steps from feat(content-gate): add per-block access control for Group, Stack, and Row blocks #4646 and confirm things look okay.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@laurelfulford laurelfulford requested a review from Copilot May 11, 2026 23:27
@laurelfulford laurelfulford changed the title Fix/remove component margins fix: prevent content-gate editor.scss styles from getting chunked into the common.css file May 11, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses unintended Gutenberg component styling bleed caused by editor.scss being imported by multiple entrypoints and ending up in a shared/common stylesheet chunk. It isolates the block visibility panel styles into a dedicated stylesheet and tweaks the generic BaseControl margin rule to avoid impacting the publish-date time UI.

Changes:

  • Switched block-visibility.tsx to import a new block-visibility.scss instead of editor.scss, preventing editor.scss from being pulled into a common chunk.
  • Extracted the block visibility panel SCSS from editor.scss into the new block-visibility.scss.
  • Adjusted .components-base-control spacing in editor.scss to exclude DateTime/time-wrapper controls.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/content-gate/editor/editor.scss Removes now-unneeded WP variables import, updates BaseControl margin behavior, and removes block-visibility panel styles (moved out).
src/content-gate/editor/block-visibility.tsx Stops importing editor.scss and imports the new, dedicated block-visibility stylesheet.
src/content-gate/editor/block-visibility.scss New isolated styles for the Access Control block visibility panel.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/content-gate/editor/editor.scss Outdated
@laurelfulford laurelfulford added [Status] Needs Review The issue or pull request needs to be reviewed labels May 11, 2026
@laurelfulford laurelfulford marked this pull request as ready for review May 11, 2026 23:47
@laurelfulford laurelfulford requested a review from a team as a code owner May 11, 2026 23:47
@adekbadek adekbadek self-assigned this May 20, 2026
Copy link
Copy Markdown
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

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

The chunking diagnosis is correct and the NPPM-2812 schedule-popup fix is verified working (the global .components-base-control margin no longer reaches commons.css). One blocker and some comments.

Comment thread src/content-gate/editor/block-visibility.tsx
Comment thread src/content-gate/editor/editor.scss
Comment thread src/content-gate/editor/editor.scss Outdated
@github-actions github-actions Bot added the [Status] Needs Changes or Feedback The issue or pull request needs action from the original creator label May 21, 2026
@laurelfulford
Copy link
Copy Markdown
Contributor Author

Thanks @adekbadek -- everything should be addressed! Can you take another peek and let me know if anything else looks amiss!

@laurelfulford laurelfulford requested a review from adekbadek May 26, 2026 21:07
Copy link
Copy Markdown
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

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

All three items addressed in code: missing CSS enqueue, newspack-content-gate-panel scoping class on Metering + PostSettings, and $grid-unit-20 token. Verified via the before/after screenshots.

@github-actions github-actions Bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed [Status] Needs Changes or Feedback The issue or pull request needs action from the original creator labels Jun 2, 2026
@laurelfulford
Copy link
Copy Markdown
Contributor Author

Thanks for the review, @adekbadek! 🙌

@laurelfulford laurelfulford merged commit 4d4c557 into release Jun 2, 2026
15 checks passed
@laurelfulford laurelfulford deleted the fix/remove-component-margins branch June 2, 2026 17:54
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

Hey @laurelfulford, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

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! ❤️

matticbot pushed a commit that referenced this pull request Jun 2, 2026
## [6.42.1](v6.42.0...v6.42.1) (2026-06-02)

### Bug Fixes

* prevent content-gate editor.scss styles from getting chunked into the common.css file ([#4716](#4716)) ([4d4c557](4d4c557))
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

🎉 This PR is included in version 6.42.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit to Automattic/newspack-workspace that referenced this pull request Jun 3, 2026
## [6.42.1](Automattic/newspack-plugin@v6.42.0...v6.42.1) (2026-06-02)

### Bug Fixes

* prevent content-gate editor.scss styles from getting chunked into the common.css file ([#4716](Automattic/newspack-plugin#4716)) ([f6e5a56](Automattic/newspack-plugin@f6e5a56))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-changelog [Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants