Skip to content

Accessibility enhancements#262

Merged
nkbt merged 5 commits into
nkbt:masterfrom
kylemh:master
Nov 19, 2020
Merged

Accessibility enhancements#262
nkbt merged 5 commits into
nkbt:masterfrom
kylemh:master

Conversation

@kylemh
Copy link
Copy Markdown

@kylemh kylemh commented Feb 16, 2020

As discussed in #255 , accessibility for collapses/accordions are difficult and not as simple as dealing with aria-hidden. I've used it anyways, but also provided a prop and documentation on how to make react-collapse usages more accessible.

Resolves #255

Comment thread src/Collapse.js Outdated
className={theme.collapse}
style={this.initialStyle}
aria-hidden={!isOpened}>
<div ref={this.onRefContent} className={theme.content} id={accessibilityId}>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why id on content element? Why not set it in your children’s parent element? What its purpose in a11y context? I can see how area-hidden can be useful, but very much against adding any extra special props, especially when they can be avoided

Copy link
Copy Markdown
Author

@kylemh kylemh Feb 16, 2020

Choose a reason for hiding this comment

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

The value one passes to id needs to match the controlling element's aria-controls value (you can see this in action via the examples I created). We can leave it to the consumer to apply id as part of the child's top-level element, but I thought it'd be cool to encourage accessibility standards by exposing the optional prop (it's a bit more "in your face").

Lemme know if you're still against the idea of it as a prop. I can edit the examples and documentation accordingly. Personally, I'd advocate the other direction and require the accessibilityId prop, but it still won't guarantee anything... I just imagine people will want to understand the prop and adhere it to it.

Copy link
Copy Markdown
Author

@kylemh kylemh Mar 27, 2020

Choose a reason for hiding this comment

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

@nkbt curious on your thoughts. You may be adding a prop to your library, but the end result for the consumer is the same if a user follows best practices with accessibility. This way, you're simply encouraging best practices and helping to create a more accessible web.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Look, I am very much against adding any props to the library unless it is absolutely impossible to do outside of the library and it is breaking intended functionality. I can understand the need for aria-hidden especially as it does not affect public API of the component itself at all, so it should be ok to add (though technically it still would be possible to overcome from outside, but the change is too unobtrusive). Everything else I don't see as part of the library, unfortunately, and would really like to avoid adding

Thank you for the change and all the reasoning though, I do appreciate your time and dedication in making web better. Legend 👍

Copy link
Copy Markdown
Author

@kylemh kylemh Mar 27, 2020

Choose a reason for hiding this comment

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

Sad to hear, but I've made adjustments that I think you'll be happy with!

Copy link
Copy Markdown
Owner

@nkbt nkbt left a comment

Choose a reason for hiding this comment

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

Thank you for the changes and great example. I will do some tests before merge, but looks good to me

@thehulke
Copy link
Copy Markdown

thehulke commented Nov 8, 2020

Hello there, any plans on merging the PR? really need this 😬

@kylemh
Copy link
Copy Markdown
Author

kylemh commented Nov 8, 2020

@thehulke

I would ditch this library and use Reach UI's Accordion component:

https://reach.tech/accordion

Accessibility is a requirement in that library.

@nkbt nkbt merged commit cc54bf8 into nkbt:master Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[A11Y] Add HTML tag "aria-hidden"

3 participants