Skip to content

Commit

Permalink
Merge pull request #9953 from abailly-akamai/M3-7477
Browse files Browse the repository at this point in the history
fix: [M3-7477] - Fix accessibility on disabled SelectRegion menu items
  • Loading branch information
abailly-akamai authored Dec 4, 2023
2 parents 0989de5 + 0980da2 commit 434917d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-9953-fixed-1701463226665.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Fix accessibility on disabled SelectRegion menu items ([#9953](https://github.com/linode/manager/pull/9953))
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ export const StyledLParentListItem = styled(ListItem, {

export const StyledListItem = styled(ListItem, {
label: 'RegionSelectListItem',
})(({ theme }) => ({
})(() => ({
'&.Mui-disabled': {
cursor: 'not-allowed',
},
'&.MuiAutocomplete-option': {
minHeight: 'auto !important',
padding: '8px 10px !important',
},
'&.MuiListItem-root[aria-disabled="true"]': {
background: 'transparent !important',
color: theme.palette.text.primary,
cursor: 'not-allowed !important',
pointerEvents: 'inherit !important',
},
'&.MuiListItem-root[aria-disabled="true"]:active': {
pointerEvents: 'none !important',
},
Expand Down
21 changes: 21 additions & 0 deletions packages/manager/src/components/RegionSelect/RegionSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { visuallyHidden } from '@mui/utils';
import * as React from 'react';

import { Autocomplete } from 'src/components/Autocomplete/Autocomplete';
Expand Down Expand Up @@ -133,19 +134,39 @@ export const RegionSelect = React.memo((props: RegionSelectProps) => {
>
<StyledListItem
{...props}
className={
isDisabledMenuItem
? `${props.className} Mui-disabled`
: props.className
}
componentsProps={{
root: {
'data-qa-option': option.value,
'data-testid': option.value,
} as ListItemComponentsPropsOverrides,
}}
onClick={(e) =>
isDisabledMenuItem
? e.preventDefault()
: props.onClick
? props.onClick(e)
: null
}
aria-disabled={undefined}
>
<>
<Box alignItems="center" display="flex" flexGrow={1}>
<StyledFlagContainer>
<Flag country={option.data.country} />
</StyledFlagContainer>
{option.label}
{isDisabledMenuItem && (
<Box sx={visuallyHidden}>
Disabled option - There may be limited capacity in this
region. Learn more at
https://www.linode.com/global-infrastructure/availability.
</Box>
)}
</Box>
{selected && <SelectedIcon visible={selected} />}
</>
Expand Down

0 comments on commit 434917d

Please sign in to comment.