Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fluffy-pugs-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Switches focus styles to target `a.focus-visible` instead of `a:focus-visible`.
4 changes: 2 additions & 2 deletions packages/react/src/ActionList/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>(
color: getVariantStyles(variant, disabled, inactive).hoverColor,
boxShadow: `inset 0 0 0 max(1px, 0.0625rem) ${theme?.colors.actionListItem.default.activeBorder}`,
},
'&:focus-visible, > a:focus-visible, &:focus.focus-visible': {
'&:focus-visible, > a.focus-visible, &:focus.focus-visible': {
outline: 'none',
border: `2 solid`,
boxShadow: `0 0 0 2px ${theme?.colors.accent.emphasis}`,
Expand All @@ -186,7 +186,7 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>(
},

'@media (forced-colors: active)': {
':focus, &:focus-visible, > a:focus-visible': {
':focus, &:focus-visible, > a.focus-visible': {
// Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips
outline: 'solid 1px transparent !important',
},
Expand Down
12 changes: 11 additions & 1 deletion packages/react/src/ActionMenu/ActionMenu.examples.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import {Box, ActionMenu, ActionList, Button, IconButton} from '../'
import {Box, ActionMenu, ActionList, Button, IconButton, FormControl, TextInput} from '../'
import {
GearIcon,
MilestoneIcon,
Expand Down Expand Up @@ -183,6 +183,15 @@ export const ShortcutMenu = () => {
<h2>Press Shift+C to open the menu</h2>
<br />

{/**
* This is used to demonstrate mouse/keyboard modality
* and how it might affect `:focus-visible` styles in the menu.
*/}
<FormControl>
<FormControl.Label>Default label</FormControl.Label>
<TextInput />
</FormControl>

{/**
* Even though the state is controlled externally,
* we can pass an Anchor for the menu to "anchor to"
Expand All @@ -209,6 +218,7 @@ export const ShortcutMenu = () => {
Edit comment
<ActionList.TrailingVisual>⌘E</ActionList.TrailingVisual>
</ActionList.Item>
<ActionList.LinkItem href="#">View file</ActionList.LinkItem>
<ActionList.Divider />
<ActionList.Item variant="danger">
Delete file
Expand Down
32 changes: 16 additions & 16 deletions packages/react/src/NavList/__snapshots__/NavList.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ exports[`NavList renders a simple list 1`] = `
}

.c2:focus-visible,
.c2 > a:focus-visible,
.c2 > a.focus-visible,
.c2:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -277,7 +277,7 @@ exports[`NavList renders a simple list 1`] = `
@media (forced-colors:active) {
.c2:focus,
.c2:focus-visible,
.c2 > a:focus-visible {
.c2 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand All @@ -290,7 +290,7 @@ exports[`NavList renders a simple list 1`] = `
}

.c7:focus-visible,
.c7 > a:focus-visible,
.c7 > a.focus-visible,
.c7:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -306,7 +306,7 @@ exports[`NavList renders a simple list 1`] = `
@media (forced-colors:active) {
.c7:focus,
.c7:focus-visible,
.c7 > a:focus-visible {
.c7 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand Down Expand Up @@ -691,7 +691,7 @@ exports[`NavList renders with groups 1`] = `
}

.c6:focus-visible,
.c6 > a:focus-visible,
.c6 > a.focus-visible,
.c6:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -707,7 +707,7 @@ exports[`NavList renders with groups 1`] = `
@media (forced-colors:active) {
.c6:focus,
.c6:focus-visible,
.c6 > a:focus-visible {
.c6 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand All @@ -720,7 +720,7 @@ exports[`NavList renders with groups 1`] = `
}

.c11:focus-visible,
.c11 > a:focus-visible,
.c11 > a.focus-visible,
.c11:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -736,7 +736,7 @@ exports[`NavList renders with groups 1`] = `
@media (forced-colors:active) {
.c11:focus,
.c11:focus-visible,
.c11 > a:focus-visible {
.c11 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand Down Expand Up @@ -1162,7 +1162,7 @@ exports[`NavList.Item with NavList.SubNav does not have active styles if SubNav
}

.c11:focus-visible,
.c11 > a:focus-visible,
.c11 > a.focus-visible,
.c11:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -1178,7 +1178,7 @@ exports[`NavList.Item with NavList.SubNav does not have active styles if SubNav
@media (forced-colors:active) {
.c11:focus,
.c11:focus-visible,
.c11 > a:focus-visible {
.c11 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand All @@ -1191,7 +1191,7 @@ exports[`NavList.Item with NavList.SubNav does not have active styles if SubNav
}

.c4:focus-visible,
.c4 > a:focus-visible,
.c4 > a.focus-visible,
.c4:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -1207,7 +1207,7 @@ exports[`NavList.Item with NavList.SubNav does not have active styles if SubNav
@media (forced-colors:active) {
.c4:focus,
.c4:focus-visible,
.c4 > a:focus-visible {
.c4 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand Down Expand Up @@ -1647,7 +1647,7 @@ exports[`NavList.Item with NavList.SubNav has active styles if SubNav contains t
}

.c11:focus-visible,
.c11 > a:focus-visible,
.c11 > a.focus-visible,
.c11:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -1663,7 +1663,7 @@ exports[`NavList.Item with NavList.SubNav has active styles if SubNav contains t
@media (forced-colors:active) {
.c11:focus,
.c11:focus-visible,
.c11 > a:focus-visible {
.c11 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand All @@ -1684,7 +1684,7 @@ exports[`NavList.Item with NavList.SubNav has active styles if SubNav contains t
}

.c4:focus-visible,
.c4 > a:focus-visible,
.c4 > a.focus-visible,
.c4:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -1700,7 +1700,7 @@ exports[`NavList.Item with NavList.SubNav has active styles if SubNav contains t
@media (forced-colors:active) {
.c4:focus,
.c4:focus-visible,
.c4 > a:focus-visible {
.c4 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ exports[`snapshots renders a menu that contains an item to add to the menu 1`] =
}

.c3:focus-visible,
.c3 > a:focus-visible,
.c3 > a.focus-visible,
.c3:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -787,7 +787,7 @@ exports[`snapshots renders a menu that contains an item to add to the menu 1`] =
@media (forced-colors:active) {
.c3:focus,
.c3:focus-visible,
.c3 > a:focus-visible {
.c3 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand Down Expand Up @@ -1524,7 +1524,7 @@ exports[`snapshots renders a multiselect input 1`] = `
}

.c3:focus-visible,
.c3 > a:focus-visible,
.c3 > a.focus-visible,
.c3:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -1540,7 +1540,7 @@ exports[`snapshots renders a multiselect input 1`] = `
@media (forced-colors:active) {
.c3:focus,
.c3:focus-visible,
.c3 > a:focus-visible {
.c3 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand Down Expand Up @@ -2336,7 +2336,7 @@ exports[`snapshots renders a multiselect input with selected menu items 1`] = `
}

.c3:focus-visible,
.c3 > a:focus-visible,
.c3 > a.focus-visible,
.c3:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -2352,7 +2352,7 @@ exports[`snapshots renders a multiselect input with selected menu items 1`] = `
@media (forced-colors:active) {
.c3:focus,
.c3:focus-visible,
.c3 > a:focus-visible {
.c3 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand All @@ -2365,7 +2365,7 @@ exports[`snapshots renders a multiselect input with selected menu items 1`] = `
}

.c8:focus-visible,
.c8 > a:focus-visible,
.c8 > a.focus-visible,
.c8:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -2381,7 +2381,7 @@ exports[`snapshots renders a multiselect input with selected menu items 1`] = `
@media (forced-colors:active) {
.c8:focus,
.c8:focus-visible,
.c8 > a:focus-visible {
.c8 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand Down Expand Up @@ -3015,7 +3015,7 @@ exports[`snapshots renders a single select input 1`] = `
}

.c3:focus-visible,
.c3 > a:focus-visible,
.c3 > a.focus-visible,
.c3:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -3031,7 +3031,7 @@ exports[`snapshots renders a single select input 1`] = `
@media (forced-colors:active) {
.c3:focus,
.c3:focus-visible,
.c3 > a:focus-visible {
.c3 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand Down Expand Up @@ -3471,7 +3471,7 @@ exports[`snapshots renders with a custom text input component 1`] = `
}

.c3:focus-visible,
.c3 > a:focus-visible,
.c3 > a.focus-visible,
.c3:focus.focus-visible {
outline: none;
border: 2 solid;
Expand All @@ -3487,7 +3487,7 @@ exports[`snapshots renders with a custom text input component 1`] = `
@media (forced-colors:active) {
.c3:focus,
.c3:focus-visible,
.c3 > a:focus-visible {
.c3 > a.focus-visible {
outline: solid 1px transparent !important;
}
}
Expand Down