-
Notifications
You must be signed in to change notification settings - Fork 870
[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
base: main
Are you sure you want to change the base?
Changes from all commits
cdb7a2a
5edcf0b
018c215
38fb290
0fa990a
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,3 @@ | ||
| **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} | ||
|
|
||
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.
Before, when using
status === 'disabled'onClickwould still be triggered which does not make sense but is a behavioral change that we didn't mention in the PR description/changelog, and can potentially break some cases if they rely on it? 🤔