Skip to content

Comments

fix(material/table): add aria-expanded to expandable rows example#32823

Open
yogeshwaran-c wants to merge 2 commits intoangular:mainfrom
yogeshwaran-c:fix/table-expandable-rows-a11y
Open

fix(material/table): add aria-expanded to expandable rows example#32823
yogeshwaran-c wants to merge 2 commits intoangular:mainfrom
yogeshwaran-c:fix/table-expandable-rows-a11y

Conversation

@yogeshwaran-c
Copy link

What kind of change does this PR introduce?

Accessibility fix (example)

What is the current behavior?

The "Table with expandable rows" example does not convey the expanded/collapsed state to assistive technology. Screen reader users have no way to know whether a row is currently expanded, and the toggle button always says "expand row" regardless of state.

Closes #15020

What is the new behavior?

  • Added [attr.aria-expanded]="isExpanded(element)" to the toggle button, so screen readers announce the expanded/collapsed state
  • Changed aria-label from a static "expand row" to a dynamic binding that says "collapse row" when expanded and "expand row" when collapsed

Additional context

The WAI-ARIA Authoring Practices recommend using aria-expanded on disclosure triggers to communicate state to assistive technology. The existing button element already provides keyboard accessibility (focusable, activatable via Enter/Space), so only the ARIA state attribute was missing.

The expandable rows table example did not convey the expanded/collapsed
state to assistive technology. Add aria-expanded to the toggle button
so screen readers announce whether a row is expanded, and update the
aria-label dynamically to reflect the current state.

Closes angular#15020
Comment on lines 15 to 16
[attr.aria-label]="isExpanded(element) ? 'collapse row' : 'expand row'"
[attr.aria-expanded]="isExpanded(element)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aria attributes are natively support since 20.2.

Suggested change
[attr.aria-label]="isExpanded(element) ? 'collapse row' : 'expand row'"
[attr.aria-expanded]="isExpanded(element)"
[aria-label]="isExpanded(element) ? 'collapse row' : 'expand row'"
[aria-expanded]="isExpanded(element)"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied — switched to native [aria-*] bindings in a277177. Ready for re-review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Demo bug: expandable row table example is not keyboard or screen reader accessible

2 participants