Skip to content

Commit

Permalink
TreeView: Fix focus styles in styled-components v5.2+ (#2375)
Browse files Browse the repository at this point in the history
* Update active descendant styles

* Update CSS selectors

* Create brown-bees-tap.md

* Add comment about CSS selectors
  • Loading branch information
colebemis authored Sep 26, 2022
1 parent 143286e commit 96f3b8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-bees-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

TreeView: Fix focus styles in styled-components v5.2+
8 changes: 6 additions & 2 deletions src/TreeView/TreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,14 @@ const Item: React.FC<TreeViewItemProps> = ({
'&:hover': {
backgroundColor: 'actionListItem.default.hoverBg'
},
[`[role=tree][aria-activedescendant="${itemId}"]:focus-visible &`]: {
// WARNING: styled-components v5.2 introduced a bug that changed
// how it expands `&` in CSS selectors. The following selectors
// are unnecessarily specific to work around that styled-components bug.
// Reference issue: https://github.com/styled-components/styled-components/issues/3265
[`[role=tree][aria-activedescendant="${itemId}"]:focus-visible #${itemId} > &:is(div)`]: {
boxShadow: (theme: Theme) => `0 0 0 2px ${theme.colors.accent.emphasis}`
},
'[role=treeitem][aria-current=true] > &': {
'[role=treeitem][aria-current=true] > &:is(div)': {
bg: 'actionListItem.default.selectedBg',
'&::after': {
position: 'absolute',
Expand Down

0 comments on commit 96f3b8a

Please sign in to comment.