-
Notifications
You must be signed in to change notification settings - Fork 650
[a11y] When aria-disabled is set on SegmentedControl, don't allow action #6516
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
Changes from all commits
27b3a27
94c4b25
46f8beb
57f988d
c2aad6e
af99208
307289d
088b051
528e05a
3b6eefe
9acdcc4
d99fc85
3984849
3b95781
9ff45d6
af884b0
c31274e
154deb0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@primer/react": minor | ||
| --- | ||
|
|
||
| Remove the feature flag for `primer_react_segmented_control_tooltip` and GA tooltip by default behavior. | ||
| - Ensure that when `disabled` is applied, the tooltip is still triggered. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,82 @@ export default { | |
| parameters: {controls: {exclude: excludedControlKeys}}, | ||
| } as Meta<typeof SegmentedControl> | ||
|
|
||
| export const WithAriaDisabled = () => { | ||
| const handleOnClick = () => { | ||
| alert('Button clicked!') | ||
| } | ||
|
|
||
| return ( | ||
| <SegmentedControl aria-label="File view" className="testCustomClassnameMono"> | ||
| <SegmentedControl.IconButton | ||
| onClick={handleOnClick} | ||
| aria-label={'Preview'} | ||
| aria-disabled={true} | ||
| icon={EyeIcon} | ||
| className="testCustomClassnameColor" | ||
| > | ||
| Preview | ||
| </SegmentedControl.IconButton> | ||
| <SegmentedControl.IconButton | ||
| aria-disabled={true} | ||
|
||
| onClick={handleOnClick} | ||
| aria-label={'Raw'} | ||
| icon={FileCodeIcon} | ||
| className="testCustomClassnameColor" | ||
| > | ||
| Raw | ||
| </SegmentedControl.IconButton> | ||
| <SegmentedControl.IconButton | ||
| aria-disabled={true} | ||
|
||
| onClick={handleOnClick} | ||
| aria-label={'Blame'} | ||
| icon={PeopleIcon} | ||
| className="testCustomClassnameColor" | ||
| > | ||
| Blame | ||
| </SegmentedControl.IconButton> | ||
| </SegmentedControl> | ||
| ) | ||
| } | ||
|
|
||
| export const WithDisabled = () => { | ||
| const handleOnClick = () => { | ||
| alert('Button clicked!') | ||
| } | ||
|
|
||
| return ( | ||
| <SegmentedControl aria-label="File view" className="testCustomClassnameMono"> | ||
| <SegmentedControl.IconButton | ||
| onClick={handleOnClick} | ||
| aria-label={'Preview'} | ||
| disabled={true} | ||
| icon={EyeIcon} | ||
| className="testCustomClassnameColor" | ||
| > | ||
| Preview | ||
| </SegmentedControl.IconButton> | ||
| <SegmentedControl.IconButton | ||
| disabled={true} | ||
| onClick={handleOnClick} | ||
| aria-label={'Raw'} | ||
| icon={FileCodeIcon} | ||
| className="testCustomClassnameColor" | ||
| > | ||
| Raw | ||
| </SegmentedControl.IconButton> | ||
| <SegmentedControl.IconButton | ||
| disabled={true} | ||
| onClick={handleOnClick} | ||
| aria-label={'Blame'} | ||
| icon={PeopleIcon} | ||
| className="testCustomClassnameColor" | ||
| > | ||
| Blame | ||
| </SegmentedControl.IconButton> | ||
| </SegmentedControl> | ||
| ) | ||
| } | ||
|
|
||
| export const WithCss = () => ( | ||
| <SegmentedControl aria-label="File view" className="testCustomClassnameMono"> | ||
| <SegmentedControl.Button | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import type {Meta} from '@storybook/react-vite' | ||
| import {SegmentedControl} from '.' | ||
| import {EyeIcon, FileCodeIcon, PeopleIcon} from '@primer/octicons-react' | ||
|
|
||
| export default { | ||
| title: 'Components/SegmentedControl/Examples', | ||
| component: SegmentedControl, | ||
| } as Meta<typeof SegmentedControl> | ||
|
|
||
| export const WithDisabledButtons = () => ( | ||
| <SegmentedControl aria-label="File view"> | ||
| <SegmentedControl.Button defaultSelected aria-label={'Preview'} leadingIcon={EyeIcon} disabled> | ||
| Preview | ||
| </SegmentedControl.Button> | ||
| <SegmentedControl.Button aria-label={'Raw'} leadingIcon={FileCodeIcon}> | ||
| Raw | ||
| </SegmentedControl.Button> | ||
| <SegmentedControl.Button aria-label={'Blame'} leadingIcon={PeopleIcon} disabled> | ||
| Blame | ||
| </SegmentedControl.Button> | ||
| </SegmentedControl> | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use boolean literal
trueinstead of{true}for boolean props. This can be simplified to justaria-disabled.