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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActionList: Fix leaky disabled description styles #4566

Merged
merged 2 commits into from May 13, 2024

Conversation

siddharthkp
Copy link
Contributor

@siddharthkp siddharthkp commented May 7, 2024

Problem

Description in a disabled item should not have color: fg.muted but the disabled color. We set this by adding the disabled color on the item and adding color:inherit on the description. Source

const styles = {
  'li[aria-disabled="true"] &': { color: 'inherit'  }
}

return <Box as="span" sx={styles}/>{props.children</Box>

This feels safe because we are only targeting Description inside li[aria-disabled=true]. This is the generated css:

li[aria-disabled="true"] .Box-sc-g0xbh4-0 {
    color: inherit;
}

The trouble here is that the generated className for '&' is not the className just for ActionList.Description but is passed to multiple elements within ActionList.Item. 馃

This really threw me off!

the className Box-sc-g0xbh4-0 is present on multiple elements

Solution

As a quick fix, I added a data-component to make the selector more specific. Expecting no visual changes, only changes in the generated css.

Before
li[aria-disabled="true"] .Box-sc-g0xbh4-0 {
    color: inherit;
}
After
li[aria-disabled="true"] .Box-sc-g0xbh4-0[data-component="ActionList.Description"] {
    color: inherit;
}

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

Merge checklist

Copy link

changeset-bot bot commented May 7, 2024

馃 Changeset detected

Latest commit: e995bb9

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

Copy link
Contributor

github-actions bot commented May 7, 2024

size-limit report 馃摝

Path Size
packages/react/dist/browser.esm.js 88.07 KB (+0.04% 馃敽)
packages/react/dist/browser.umd.js 88.43 KB (+0.06% 馃敽)

@siddharthkp siddharthkp self-assigned this May 7, 2024
@siddharthkp siddharthkp added bug Something isn't working patch release bug fixes, docs, housekeeping labels May 7, 2024
@siddharthkp siddharthkp marked this pull request as ready for review May 7, 2024 14:50
@siddharthkp siddharthkp requested a review from a team as a code owner May 7, 2024 14:50
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.

// huh why?

馃槃

Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

@siddharthkp wanted to ask if this is possible to capture in VRT or nah? (Or is it already?)

@siddharthkp
Copy link
Contributor Author

siddharthkp commented May 8, 2024

wanted to ask if this is possible to capture in VRT or nah? (Or is it already?)

Maybe but not a clean one. The instance where this happens in gh/gh is also not the best use case for ActionList

@siddharthkp siddharthkp added this pull request to the merge queue May 13, 2024
Merged via the queue into main with commit 4dd6bef May 13, 2024
32 of 33 checks passed
@siddharthkp siddharthkp deleted the actionlist-fix-description-styles branch May 13, 2024 14:39
@primer primer bot mentioned this pull request May 9, 2024
JelloBagel pushed a commit that referenced this pull request May 16, 2024
* replace leaky & with data-component

* Create stupid-stingrays-sparkle.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working patch release bug fixes, docs, housekeeping
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants