Skip to content

Commit a08997b

Browse files
authored
fix(TreeView): add outline transparent for visible focus indicators (#2433)
* fix(TreeView): add outline transparent for visible focus indicators * fix(TreeView): update hover styles for WHCM * chore: add changeset
1 parent 76a3115 commit a08997b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.changeset/large-bulldogs-dance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Update TreeView hover and focus styles to work in Windows High Contrast Mode

src/TreeView/TreeView.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,11 @@ const Item: React.FC<TreeViewItemProps> = ({
216216
borderRadius: 2,
217217
cursor: 'pointer',
218218
'&:hover': {
219-
backgroundColor: 'actionListItem.default.hoverBg'
219+
backgroundColor: 'actionListItem.default.hoverBg',
220+
'@media (forced-colors: active)': {
221+
outline: '2px solid transparent',
222+
outlineOffset: -2
223+
}
220224
},
221225
'@media (pointer: coarse)': {
222226
'--toggle-width': '1.5rem', // 24px
@@ -227,7 +231,11 @@ const Item: React.FC<TreeViewItemProps> = ({
227231
// are unnecessarily specific to work around that styled-components bug.
228232
// Reference issue: https://github.com/styled-components/styled-components/issues/3265
229233
[`[role=tree][aria-activedescendant="${itemId}"]:focus-visible #${itemId} > &:is(div)`]: {
230-
boxShadow: (theme: Theme) => `inset 0 0 0 2px ${theme.colors.accent.emphasis}`
234+
boxShadow: (theme: Theme) => `inset 0 0 0 2px ${theme.colors.accent.emphasis}`,
235+
'@media (forced-colors: active)': {
236+
outline: '2px solid SelectedItem',
237+
outlineOffset: -2
238+
}
231239
},
232240
'[role=treeitem][aria-current=true] > &:is(div)': {
233241
bg: 'actionListItem.default.selectedBg',

0 commit comments

Comments
 (0)