Skip to content
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

[EuiAccordion] Fixed a bug in aria-expanded for axe-core. #6694

Merged
merged 7 commits into from
Apr 6, 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
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@ exports[`EuiAccordion props buttonElement is rendered 1`] = `
</button>
<div
aria-controls="5"
aria-expanded="false"
class="euiAccordion__button emotion-euiAccordion__button"
id="generated-id"
>
Expand Down Expand Up @@ -688,7 +687,6 @@ exports[`EuiAccordion props element is rendered 1`] = `
</button>
<legend
aria-controls="1"
aria-expanded="false"
class="euiAccordion__button emotion-euiAccordion__button"
id="generated-id"
>
Expand Down
3 changes: 2 additions & 1 deletion src/components/accordion/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ export class EuiAccordionClass extends Component<
id={buttonId}
className={buttonClasses}
aria-controls={id}
aria-expanded={isOpen}
// `aria-expanded` is only a valid attribute on interactive controls - axe-core throws a violation otherwise
aria-expanded={ButtonElement === 'button' ? isOpen : undefined}
onClick={isDisabled ? undefined : this.onToggle}
type={ButtonElement === 'button' ? 'button' : undefined}
disabled={ButtonElement === 'button' ? isDisabled : undefined}
Expand Down
3 changes: 3 additions & 0 deletions upcoming_changelogs/6694.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Bug fixes**

- Fixed `EuiAccordion` to not set an `aria-expanded` attribute on non-interactive `buttonElement`s