Skip to content

Commit

Permalink
[docs] Fix a11y in Menu demos (#30378)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeshanTamboli authored Dec 24, 2021
1 parent 83b7ea0 commit c0183d9
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 13 deletions.
10 changes: 9 additions & 1 deletion docs/src/pages/components/menus/AccountMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,21 @@ export default function AccountMenu() {
<Typography sx={{ minWidth: 100 }}>Contact</Typography>
<Typography sx={{ minWidth: 100 }}>Profile</Typography>
<Tooltip title="Account settings">
<IconButton onClick={handleClick} size="small" sx={{ ml: 2 }}>
<IconButton
onClick={handleClick}
size="small"
sx={{ ml: 2 }}
aria-controls={open ? 'account-menu' : undefined}
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
>
<Avatar sx={{ width: 32, height: 32 }}>M</Avatar>
</IconButton>
</Tooltip>
</Box>
<Menu
anchorEl={anchorEl}
id="account-menu"
open={open}
onClose={handleClose}
onClick={handleClose}
Expand Down
10 changes: 9 additions & 1 deletion docs/src/pages/components/menus/AccountMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,21 @@ export default function AccountMenu() {
<Typography sx={{ minWidth: 100 }}>Contact</Typography>
<Typography sx={{ minWidth: 100 }}>Profile</Typography>
<Tooltip title="Account settings">
<IconButton onClick={handleClick} size="small" sx={{ ml: 2 }}>
<IconButton
onClick={handleClick}
size="small"
sx={{ ml: 2 }}
aria-controls={open ? 'account-menu' : undefined}
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
>
<Avatar sx={{ width: 32, height: 32 }}>M</Avatar>
</IconButton>
</Tooltip>
</Box>
<Menu
anchorEl={anchorEl}
id="account-menu"
open={open}
onClose={handleClose}
onClick={handleClose}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/menus/BasicMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function BasicMenu() {
<div>
<Button
id="basic-button"
aria-controls="basic-menu"
aria-controls={open ? 'basic-menu' : undefined}
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
onClick={handleClick}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/menus/BasicMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function BasicMenu() {
<div>
<Button
id="basic-button"
aria-controls="basic-menu"
aria-controls={open ? 'basic-menu' : undefined}
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
onClick={handleClick}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/menus/CustomizedMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function CustomizedMenus() {
<div>
<Button
id="demo-customized-button"
aria-controls="demo-customized-menu"
aria-controls={open ? 'demo-customized-menu' : undefined}
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
variant="contained"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/menus/CustomizedMenus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function CustomizedMenus() {
<div>
<Button
id="demo-customized-button"
aria-controls="demo-customized-menu"
aria-controls={open ? 'demo-customized-menu' : undefined}
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
variant="contained"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/menus/FadeMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function FadeMenu() {
<div>
<Button
id="fade-button"
aria-controls="fade-menu"
aria-controls={open ? 'fade-menu' : undefined}
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
onClick={handleClick}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/menus/FadeMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function FadeMenu() {
<div>
<Button
id="fade-button"
aria-controls="fade-menu"
aria-controls={open ? 'fade-menu' : undefined}
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
onClick={handleClick}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/menus/LongMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function LongMenu() {
<IconButton
aria-label="more"
id="long-button"
aria-controls="long-menu"
aria-controls={open ? 'long-menu' : undefined}
aria-expanded={open ? 'true' : undefined}
aria-haspopup="true"
onClick={handleClick}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/menus/LongMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function LongMenu() {
<IconButton
aria-label="more"
id="long-button"
aria-controls="long-menu"
aria-controls={open ? 'long-menu' : undefined}
aria-expanded={open ? 'true' : undefined}
aria-haspopup="true"
onClick={handleClick}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/menus/PositionedMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function PositionedMenu() {
<div>
<Button
id="demo-positioned-button"
aria-controls="demo-positioned-menu"
aria-controls={open ? 'demo-positioned-menu' : undefined}
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
onClick={handleClick}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/menus/PositionedMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function PositionedMenu() {
<div>
<Button
id="demo-positioned-button"
aria-controls="demo-positioned-menu"
aria-controls={open ? 'demo-positioned-menu' : undefined}
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
onClick={handleClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ export default function useAutocomplete(props) {
// only have an opinion about this when closed
'aria-activedescendant': popupOpen ? '' : null,
'aria-autocomplete': autoComplete ? 'both' : 'list',
'aria-controls': listboxAvailable ? `${id}-listbox` : null,
'aria-controls': listboxAvailable ? `${id}-listbox` : undefined,
// Disable browser's suggestion that might overlap with the popup.
// Handle autocomplete but not autofill.
autoComplete: 'off',
Expand Down

0 comments on commit c0183d9

Please sign in to comment.