Skip to content

SegmentedControl: Remove tooltip temporarily and add an accessible name to the button #3010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 13, 2023
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/violet-phones-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

SegmentedControl: Resolve axe-violation by adding a discernible text to the icon button and removing the tooltip until it is marked as accessible
23 changes: 11 additions & 12 deletions src/SegmentedControl/SegmentedControlIconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {IconProps} from '@primer/octicons-react'
import styled from 'styled-components'
import sx, {merge, SxProp} from '../sx'
import {getSegmentedControlButtonStyles, getSegmentedControlListItemStyles} from './getSegmentedControlStyles'
import Tooltip from '../Tooltip'
import Box from '../Box'
import {defaultSxProp} from '../utils/defaultSxProp'

Expand Down Expand Up @@ -45,17 +44,17 @@ export const SegmentedControlIconButton: React.FC<React.PropsWithChildren<Segmen

return (
<Box as="li" sx={mergedSx}>
<Tooltip text={ariaLabel}>
<SegmentedControlIconButtonStyled
aria-current={selected}
sx={getSegmentedControlButtonStyles({selected, isIconOnly: true})}
{...rest}
>
<span className="segmentedControl-content">
<Icon />
</span>
</SegmentedControlIconButtonStyled>
</Tooltip>
{/* TODO: Once the tooltip remediations are resolved (especially https://github.com/github/primer/issues/1909) - bring it back */}
<SegmentedControlIconButtonStyled
aria-label={ariaLabel}
aria-current={selected}
sx={getSegmentedControlButtonStyles({selected, isIconOnly: true})}
{...rest}
>
<span className="segmentedControl-content">
<Icon />
</span>
</SegmentedControlIconButtonStyled>
</Box>
)
}
Expand Down