-
Notifications
You must be signed in to change notification settings - Fork 875
[EuiStepsHorizontal][A11y] Prevent screen reader duplication #9574
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
cdb7a2a
5edcf0b
018c215
38fb290
0fa990a
c94677e
36d1937
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,5 @@ | ||
| - Updated `EuiStepsHorizontal` to prevent steps being clickable when `status="disabled"` | ||
|
|
||
| **Accessibility** | ||
|
|
||
| - Fixed duplicate screen reader output for `EuiStepsHorizontal` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,8 @@ export const EuiStepHorizontal: FunctionComponent<EuiStepHorizontalProps> = ({ | |
| disabled, | ||
| status = 'incomplete', | ||
| size = 'm', | ||
| 'aria-label': ariaLabel, | ||
| 'aria-labelledby': ariaLabelledby, | ||
| ...rest | ||
| }) => { | ||
| if (disabled) status = 'disabled'; | ||
|
|
@@ -96,7 +98,7 @@ export const EuiStepHorizontal: FunctionComponent<EuiStepHorizontalProps> = ({ | |
| status === 'disabled' && titleStyles.disabled, | ||
| ]; | ||
|
|
||
| const titleAttrsMap: Record<EuiStepStatus | 'step', string> = { | ||
| const labelMap: Record<EuiStepStatus | 'step', string> = { | ||
| step: useI18nStep({ number: step, title }), | ||
| current: useI18nCurrentStep({ number: step, title }), | ||
| disabled: useI18nDisabledStep({ number: step, title }), | ||
|
|
@@ -106,19 +108,20 @@ export const EuiStepHorizontal: FunctionComponent<EuiStepHorizontalProps> = ({ | |
| danger: useI18nErrorsStep({ number: step, title }), | ||
| loading: useI18nLoadingStep({ number: step, title }), | ||
| }; | ||
| const titleAttr = titleAttrsMap[status || 'step']; | ||
| const ariaLabelAttr = labelMap[status || 'step']; | ||
|
|
||
| const onStepClick = ( | ||
| event: ReactMouseEvent<HTMLButtonElement, MouseEvent> | ||
| ) => { | ||
| if (!disabled) onClick(event); | ||
| if (!disabled && status !== 'disabled') onClick(event); | ||
| }; | ||
|
|
||
| return ( | ||
| <button | ||
| aria-disabled={status === 'disabled' ? true : undefined} | ||
| className={classes} | ||
| title={titleAttr} | ||
| aria-label={ariaLabel ?? (ariaLabelledby ? undefined : ariaLabelAttr)} | ||
| aria-labelledby={ariaLabelledby} | ||
| onClick={onStepClick} | ||
| disabled={disabled} | ||
|
Comment on lines
121
to
126
|
||
| css={cssStyles} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.