Skip to content
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

fix: Add :where selector to classes that land on nodes that have a sx prop #4870

Merged
merged 2 commits into from
Aug 22, 2024

Conversation

jonrohan
Copy link
Member

@jonrohan jonrohan commented Aug 21, 2024

This addresses a regression found in the last release of PRC https://github.com/github/github/pull/338276#issuecomment-2301557787

The problem is when the component has an sx= prop applied to it, the styled-components styles are being overridden by the CSS modules styles. This is because the two classes have equal specificity 0,1,0.

The solution here is to add the :where selector to the CSS modules classes whenever they might exist on the same dom node as a sx prop. This will give the CSS modules classes a lower specificity 0,0,0 and will prevent the styled-components styles from being overridden.

Before

CleanShot 2024-08-21 at 11 56 45@2x

After

CleanShot 2024-08-21 at 11 56 54@2x

Changelog

Changed

Add :where() selector to classes that land on nodes that have a sx prop.

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

I'm going to test this locally, then also on a review-lab instance.

Merge checklist

@jonrohan jonrohan requested a review from a team as a code owner August 21, 2024 18:48
@jonrohan jonrohan requested a review from camertron August 21, 2024 18:48
Copy link

changeset-bot bot commented Aug 21, 2024

🦋 Changeset detected

Latest commit: 29465d6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the staff Author is a staff member label Aug 21, 2024
Copy link
Contributor

github-actions bot commented Aug 21, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 96.2 KB (0%)
packages/react/dist/browser.umd.js 96.54 KB (0%)

Copy link
Contributor

Uh oh! @jonrohan, the image you shared is missing helpful alt text. Check your pull request body.

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

@primer-integration
Copy link

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/338618

Copy link
Contributor

@langermank langermank left a comment

Choose a reason for hiding this comment

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

Awesome!

@jonrohan jonrohan added this pull request to the merge queue Aug 22, 2024
Merged via the queue into main with commit 3ca513c Aug 22, 2024
31 checks passed
@jonrohan jonrohan deleted the css_module_where_classes branch August 22, 2024 13:57
@primer primer bot mentioned this pull request Aug 22, 2024
@primer primer bot mentioned this pull request Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
staff Author is a staff member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants