[UI Component]: Fix aria hidden#1192
Conversation
|
Hey, thanks for this! I'll leave it to my colleagues to review the rest of the commit, but could you revert the inclusion of |
|
Hi @joshbruce, thanks for the PR. What do you mean by "causes double-click requirement"? |
| } | ||
| } | ||
|
|
||
| .usa-accordion-content-collapsed { |
There was a problem hiding this comment.
Is there a reason we need the accordion to have it's own class for display none, or should this be put in a general utility?
There was a problem hiding this comment.
What about what's done here: https://github.com/frend/frend.co/blob/gh-pages/_components/accordion/accordion.css
http://frend.co/components/accordion/
.usa-accordion-content[aria-hidden="true"] {
visibility: hidden;
height: 0;
}
There was a problem hiding this comment.
@msecret - Interesting suggestion. I'm not sure I'm seeing the utility solution that you might be. If we make a mixin for display: none, wouldn't we still need to @include it somewhere that distinguishes the two states?
@maya - Seems an interesting alternative. After looking at the JavaScript for the Frend accordion, it appears, to overcome setting height: 0 by calculating heights for the expanded accordions - might need to test and verify. If so, it would be more JavaScript dependence to make the accordions expand (#1121 & #1122) - unlike the display: block route. See lines 90 through 122.
There was a problem hiding this comment.
@joshbruce you're right, there may not be any benefit to the visibility: hidden method, that I could think of. We'll need to do more research. Anyhow, I tried a simple, classless method here: #1196. I'd like to hear what others think.
There was a problem hiding this comment.
@maya - Saw that. It's good solution. Incorporated it here. Also tested just doing height: auto, which did work - no JS changes needed. I do like the height solution from the screen-reader perspective - though I'm not sure if visibility: hidden would cause it to be skipped. Which brings up the question: Do we want accordion content to be hidden from screen-readers?
|
@msecret - Good question. When I used the following with
And the following to
It would require hitting the accordion button twice to actually get it to collapse or expand, respectively. Therefore, I may have misinterpreted what |
|
@yozlet - Hey. Sorry, I missed your request for the revert on
And, of course, In PHP (using Composer) we sometimes ignore If there's something we can do to make a fresh clone (or fork) work without needing |
| } | ||
|
|
||
| // Aria hidden helper | ||
| @mixin aria-hidden() { |
There was a problem hiding this comment.
I think when I said a global utility, I mean a class, such as .hidden. Sorry for the confusion. Although, what might be the benefits of using a mixin like this? It might be a better solution.
There was a problem hiding this comment.
@msecret I'd be careful about calling it .hidden, so it doesn't get confused with the hidden attribute. Although that might have been just an example or it might be ok?
Also not sure I'd call the mixin aria-hidden either bc its not the true function of aria-hidden, just a special use case for this situation. Curious to here what are the benefits of using the mixin is too. Are we reusing this somewhere else?
There was a problem hiding this comment.
@msecret: @joshbruce explained the benefits of the mixin in #1196:
To allow developers to
@includewithin any class or element; thereby, allowing any element to opt-in to being toggled based onaria-hiddenstate based on CSS
My question is the same: do we see this as a common pattern/use case?
There was a problem hiding this comment.
@msecret & @maya - I think having it as a mixin also establishes a pattern of how to handle display: none related specifically to accessibility considerations - similar to the unstyled-list mixin.
I don't think this particular pattern is used with any other UI component. I think the problem we were trying to solve initially was that aria-hidden shouldn't display: none on elements that use that attribute setting. @maya's simple solution solves this problem and limits its scope to the accordion-content class. This PR extends the flexibility of that implementation, which may be a pre-optimization (capability with no demand from developers, internal nor external)...??
There was a problem hiding this comment.
Thanks for the explanation @joshbruce , I think you've convinced me that the mixin is a good way to go. I'd agree with @maya that we should come up with a better name for it though.
There was a problem hiding this comment.
@joshbruce can you change the mixin name to accessibly-hidden?
|
@joshbruce I believe |
|
@joshbruce |
|
@maya - Sorry. Thought that was a typo. :) |
|
@joshbruce: Thank you! Nearly done - |
|
@maya @joshbruce sorry I've been mia; I'm starting to feel like the wheels came off the wagon a bit with the aria-hidden/display none rules... why are we tying I'm also a bit confused by the request to use class name I understand the impetus behind not simply removing the Thanks for your consideration and esp @joshbruce your great work and persistence in making this fix happen! I am able to override the rule for the time being but putting |
|
@yozlet - Did a copy-paste from @ducklet - I asked a similar question in the comments and have decided to leave it to the judgement of the Standards team. I believe this particular concept is the notion of an assistive technology consideration driving sighted user's experience. So, instead of I believe the choice for naming is based on the fact that it is directly tied to the From looking at the line notes - the additional class was the original solution provided - the concern there was creating "yet another class" for adopters to use and remember. Though this fix does not necessarily remove the learning it - it does keep the class list one smaller than the other solution - while allowing adopters to add the @mixin to an element they so choose; therefore, adding I agree that Cheers! Looking forward to seeing how this goes. :) |
|
@ducklet What @joshbruce stated is correct. The mixin allows us to hide things dynamically based on the |
|
These changes look good to me. Thanks again for your help, @joshbruce! 🎉 |
|
@maya this is merged but just something to think about moving forward, the problem with the abstract concepts we're now discussing is that bottom line, aria-hidden would never be used with display: none. WebAim cautions that mis-using ARIA roles can be as bad or worse than not using them, and ignoring the fundamentals breeds bad practices. I don't mean to harp but I do feel strongly that attaching our own interests to something like this is a slippery slope. |
See PR #1160
Fixes #1181 - toggleClass(), within the hide or show functions, causes
double-click requirement - if show-hide functionality is encapsulated,
toggleClass(). Encapsulation would probably reduce code readability.
Fixes #1120