Skip to content

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

Merged
jonrohan merged 2 commits into
mainfrom
css_module_where_classes
Aug 22, 2024
Merged

fix: Add :where selector to classes that land on nodes that have a sx prop#4870
jonrohan merged 2 commits into
mainfrom
css_module_where_classes

Conversation

@jonrohan

@jonrohanjonrohan commented Aug 21, 2024

Copy link
Copy Markdown
Member

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 ownerAugust 21, 2024 18:48
@changeset-bot

changeset-botBot commented Aug 21, 2024

Copy link
Copy Markdown

🦋 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
NameType
@primer/reactPatch

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-actionsgithub-actionsBot added the staff Author is a staff member label Aug 21, 2024
@github-actions

github-actionsBot commented Aug 21, 2024

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
packages/react/dist/browser.esm.js96.2 KB (0%)
packages/react/dist/browser.umd.js96.54 KB (0%)

@github-actions

Copy link
Copy Markdown
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
Copy Markdown

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

@langermanklangermank left a comment

Copy link
Copy Markdown
Contributor

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 queueAug 22, 2024
Merged via the queue into main with commit 3ca513cAug 22, 2024
@jonrohan
jonrohan deleted the css_module_where_classes branch August 22, 2024 13:57
@primerprimerBot mentioned this pull request Aug 22, 2024
@primerprimerBot mentioned this pull request Oct 18, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

staffAuthor is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@jonrohan@keithamus@langermank