Skip to content

Commit e5cf4b2

Browse files
committed
Fix Accessibility: Add focus-visible styles with outlineOffset to various components
1 parent 69d7e32 commit e5cf4b2

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

src/components/nav-drawer.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,19 @@ function NavDrawer() {
7676

7777
return (
7878
<>
79-
<Button aria-label="Menu" aria-expanded={open} onClick={() => setOpen(true)} sx={{ml: 3}}>
79+
<Button
80+
aria-label="Menu"
81+
aria-expanded={open}
82+
onClick={() => setOpen(true)}
83+
sx={{
84+
ml: 3,
85+
'&:focus-visible': {
86+
outline: '2px solid',
87+
outlineColor: '-webkit-focus-ring-color',
88+
outlineOffset: '1px',
89+
},
90+
}}
91+
>
8092
<ThreeBarsIcon />
8193
</Button>
8294
<LightTheme as={Drawer} isOpen={open} onDismiss={() => setOpen(false)}>
@@ -111,7 +123,17 @@ function NavDrawer() {
111123
}}
112124
>
113125
<SiteTitle />
114-
<Button aria-label="Close" onClick={() => setOpen(false)}>
126+
<Button
127+
aria-label="Close"
128+
onClick={() => setOpen(false)}
129+
sx={{
130+
'&:focus-visible': {
131+
outline: '2px solid',
132+
outlineColor: 'accent.fg',
133+
outlineOffset: '2px',
134+
},
135+
}}
136+
>
115137
<XIcon />
116138
</Button>
117139
</DarkTheme>

src/components/search.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,18 @@ export const Mobile = ({
113113
return (
114114
<>
115115
{!isMobileSearchOpen && (
116-
<Button aria-label="Search" aria-expanded={isMobileSearchOpen} onClick={handleSearchToggle}>
116+
<Button
117+
aria-label="Search"
118+
aria-expanded={isMobileSearchOpen}
119+
onClick={handleSearchToggle}
120+
sx={{
121+
'&:focus-visible': {
122+
outline: '2px solid',
123+
outlineColor: '-webkit-focus-ring-color',
124+
outlineOffset: '1px',
125+
},
126+
}}
127+
>
117128
<SearchIcon />
118129
</Button>
119130
)}

src/components/table-of-contents.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const Mobile = withTableOfContents(({items}) => {
5656
'&:focus-visible': {
5757
outline: '2px solid',
5858
outlineColor: '-webkit-focus-ring-color',
59+
outlineOffset: '1px',
5960
},
6061
}}
6162
leadingIcon={open ? ChevronDownIcon : ChevronRightIcon}

src/components/variant-select.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const VariantMenu = ({title, latest, current, prerelease, legacy}) => {
6060
'&:focus-visible': {
6161
outline: '2px solid',
6262
outlineColor: '-webkit-focus-ring-color',
63+
outlineOffset: '1px',
6364
},
6465
}}
6566
>

src/mdx/code.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const ClipboardCopy = ({value, ...props}) => {
3636
'&:focus-visible': {
3737
outline: '2px solid',
3838
outlineColor: '-webkit-focus-ring-color',
39+
outlineOffset: '1px',
3940
},
4041
}}
4142
>

0 commit comments

Comments
 (0)