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

fix(Section): make collapsible keyboard accessible #7144

Conversation

bvandercar-vt
Copy link
Contributor

Make collapsible header keyboard accessible. To prevent nested interactives, make the chevron the actual "button" that keyboard tabs to to expand/collapse. The whole header still expands/collapses as well, from a mouse standpoint.

@ashleighp13 ashleighp13 requested a review from jscheiny January 13, 2025 19:04
@jscheiny
Copy link
Contributor

I don't think this is the correct approach. The icon here is not a button, the whole header acts as the interactive zone, I think we should mirror this in the keyboard accessibility and make the header focusable.

@bvandercar-vt
Copy link
Contributor Author

bvandercar-vt commented Jan 22, 2025

the whole header acts as the interactive zone, I think we should mirror this in the keyboard accessibility and make the header focusable.

From a screenreader standpoint, we don't really care which element is actually the effective interactive button (has onClick), we just want a something good to bring focus to. The icon may as well be that button, it makes no difference to a screenreader.

Here's why the header being the focusable item is the wrong choice:

  • This leads to the screenreader reading a bunch of extra text on this item, such as the header title and whatever else is included in the header, such as the rightElement. It doesn't really tell you what the button actually does (expand/collapse). Making the icon the focusable button allows us to actually provide an accurate description of what it does.
  • Making the whole header the focusable button actually breaks accessibility when other interactive elements are within it, such as when a consumer wants to pass a button in the rightElement

Copy link
Contributor

@jscheiny jscheiny left a comment

Choose a reason for hiding this comment

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

Thanks for the clear and helpful explanation, LGTM

@jscheiny jscheiny merged commit 4f71978 into palantir:develop Feb 5, 2025
13 of 14 checks passed
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.

2 participants