Skip to content

Commit 32c64a6

Browse files
authored
[Fix Accessibility] Add focus-visible styles to keyboard navigation (#1722)
## 📁 File Changes (5 files modified): - `nav-drawer.js` - Added focus-visible styles to mobile menu button - `search.js` - Added focus-visible styles to mobile search button - `table-of-contents.js` - Added focus-visible styles to mobile TOC summary button - `variant-select.js` - Added focus-visible styles to CLI version selector button - `code.js` - Updated outlineOffset from 2px to 1px for clipboard copy button ## 📋 Summary: This PR improves keyboard accessibility by adding consistent focus-visible outline styles to interactive buttons across mobile components, ensuring better visual feedback for keyboard navigation users. ### `Keyboard focus indicator is not visible on 'search' icon` <img width="702" height="635" alt="image" src="https://github.com/user-attachments/assets/cd462a2e-49e1-4f42-8355-c459f601c10a" /> ### `Keyboard focus indicator is not visible on the 'Select CLI Version' button` <img width="687" height="635" alt="image" src="https://github.com/user-attachments/assets/3435c1e1-f508-4031-bbb1-e6b70fb3b88b" /> ### `Keyboard focus indicator is not visible on 'Table of contents` <img width="687" height="635" alt="image" src="https://github.com/user-attachments/assets/dafabd03-fece-4245-8d2a-b6ef0c27c163" />
1 parent 395867f commit 32c64a6

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

src/components/nav-drawer.js

Lines changed: 13 additions & 1 deletion
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)}>

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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ export const Mobile = withTableOfContents(({items}) => {
5353
borderBottomWidth: open ? 1 : 0,
5454
borderBottomLeftRadius: open ? 0 : 2,
5555
borderBottomRightRadius: open ? 0 : 2,
56+
'&:focus-visible': {
57+
outline: '2px solid',
58+
outlineColor: '-webkit-focus-ring-color',
59+
outlineOffset: '1px',
60+
},
5661
}}
5762
leadingIcon={open ? ChevronDownIcon : ChevronRightIcon}
5863
>

src/components/variant-select.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,17 @@ const VariantMenu = ({title, latest, current, prerelease, legacy}) => {
5353
Select CLI Version:
5454
</Box>
5555
<ActionMenu anchorRef={anchorRef} open={open} onOpenChange={setOpen}>
56-
<ActionMenu.Button aria-describedby={labelId} sx={{width: ['100%', null, 'auto']}}>
56+
<ActionMenu.Button
57+
aria-describedby={labelId}
58+
sx={{
59+
width: ['100%', null, 'auto'],
60+
'&:focus-visible': {
61+
outline: '2px solid',
62+
outlineColor: '-webkit-focus-ring-color',
63+
outlineOffset: '1px',
64+
},
65+
}}
66+
>
5767
{title}
5868
</ActionMenu.Button>
5969
<StyledOverlay width="auto" onEscape={() => setOpen(false)}>

src/mdx/code.js

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

0 commit comments

Comments
 (0)