Skip to content

[UI Component]: Fix aria hidden#1192

Merged
maya merged 8 commits into
uswds:stagingfrom
joshbruce:fix-aria-hidden
May 31, 2016
Merged

[UI Component]: Fix aria hidden#1192
maya merged 8 commits into
uswds:stagingfrom
joshbruce:fix-aria-hidden

Conversation

@joshbruce

Copy link
Copy Markdown

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

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
@joshbruce

Copy link
Copy Markdown
Author

Adding from #1160:

@msecret, @ducklet, @rogeruiz, @maya

@yozlet

yozlet commented May 25, 2016

Copy link
Copy Markdown
Contributor

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 Gemfile.lock? Those gems are due for an update but we should do that in a separate commit in case it breaks something.

@msecret

msecret commented May 25, 2016

Copy link
Copy Markdown
Contributor

Hi @joshbruce, thanks for the PR. What do you mean by "causes double-click requirement"?

}
}

.usa-accordion-content-collapsed {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

@maya maya May 25, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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;
}

@joshbruce joshbruce May 25, 2016

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@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.

@maya maya May 26, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@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?

@joshbruce

Copy link
Copy Markdown
Author

@msecret - Good question.

When I used the following with hide:

$content.toggleClass('accordion-content accordion-content-collapsed');

And the following to show:

$content.toggleClass('accordion-content-collapsed accordion-content');

It would require hitting the accordion button twice to actually get it to collapse or expand, respectively. Therefore, I may have misinterpreted what toggleClass() really did under the hood. It appears it will either add, or remove, a class if the class is set or not; however, it will not change one class name into another class name.

@joshbruce

Copy link
Copy Markdown
Author

@maya and @msecret - Updated PR, with both the simple (#1196) and utility concepts. Can always rollback and update PR, if desired. However, I do appreciate Maya's simple solution.

@joshbruce

joshbruce commented May 26, 2016

Copy link
Copy Markdown
Author

@yozlet - Hey. Sorry, I missed your request for the revert on Gemfile.lock. Because I had to start fresh from a new fork - long story - I had to run $ bundle update (tried running just $ npm install - did not seem to work). See my comment on #1128

Ran into this error today when doing
$ gulp website:serve
website:serve jekyll 3.1.3 | Error: kramdown
Not sure why, given that kramdown is not used - unless it is a dependency for red carpet.

And, of course, $ bundle update rewrites the Gemfile.lock.

In PHP (using Composer) we sometimes ignore composer.lock file in .gitignore to try and overcome this. Could do the same thing in Gemfile with specific version numbers instead of just the gem name and .gitignore the .lock file.

If there's something we can do to make a fresh clone (or fork) work without needing $ bundle update - let me know; otherwise, I'm not sure I can revert the file by itself. Or, of course, I could be do something wrong on the fork-clone front.

Comment thread src/stylesheets/core/_utilities.scss Outdated
}

// Aria hidden helper
@mixin aria-hidden() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@maya maya May 26, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@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?

@maya maya May 26, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@msecret: @joshbruce explained the benefits of the mixin in #1196:

To allow developers to @include within any class or element; thereby, allowing any element to opt-in to being toggled based on aria-hidden state based on CSS

My question is the same: do we see this as a common pattern/use case?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@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)...??

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@joshbruce can you change the mixin name to accessibly-hidden?

@yozlet

yozlet commented May 27, 2016

Copy link
Copy Markdown
Contributor

@joshbruce I believe git checkout 35bc35b Gemfile.lock will revert the file to the previous version, but it'll need another commit. It's weird that bundle install didn't work, though! Can you try it again after doing the revert? (And whether it works or not, I'd much prefer we leave Gemfile.lock as the old version for this PR, but we can update it in another one.)

@joshbruce

Copy link
Copy Markdown
Author

@yozlet - Done. Thanks for the instructions there. It appears there is a deletion from what in the current project: "bundled with 1.12.3"

@maya - @mixin name changed.

@maya

maya commented May 29, 2016

Copy link
Copy Markdown
Contributor

@joshbruce accessibly-hidden please, that says accessibility-.

@joshbruce

Copy link
Copy Markdown
Author

@maya - Sorry. Thought that was a typo. :)

@yozlet

yozlet commented May 31, 2016

Copy link
Copy Markdown
Contributor

@joshbruce: Thank you! Nearly done - go_script needs to come out too (it was pulled out in the main repo 5 days ago). Sorry, it's a moving target!

@ducklet

ducklet commented May 31, 2016

Copy link
Copy Markdown

@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 display: none into aria-hidden at all? Having both is redundant. Imho it would make more sense to simply create a class with rule display: none.

I'm also a bit confused by the request to use class name accessibly-hidden. Maybe there's another logic that's escaping me, but content with display: none is inherently not accessible, to anyone.

I understand the impetus behind not simply removing the display: none rule from aria-hidden, but I fear we may be dragging this out and adding unnecessary complexity to the accordion fix. Could we consider just a "use this to hide something until it's exposed" class, be it specific to the accordion or more versatile for other potential future usages?

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 !important in our code to override !important feels icky :)

@joshbruce

Copy link
Copy Markdown
Author

@yozlet - Did a copy-paste from staging as of today.

@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 display: none (sighted experience) being the driving force for assistive technologies, we allow assistive technology state aria-hidden=true to drive the visual experience. This would help adopters use this accessibility-first pattern more easily.

I believe the choice for naming is based on the fact that it is directly tied to the aria-hidden=true state; therefore, directly related to an accessibility consideration - not just display: none.

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 display: none to any element with aria-hidden=true.

I agree that !important is icky - and I believe the Standards has attempted to remove its use altogether.

Cheers! Looking forward to seeing how this goes. :)

@maya

maya commented May 31, 2016

Copy link
Copy Markdown
Contributor

@ducklet What @joshbruce stated is correct. The mixin allows us to hide things dynamically based on the aria-hidden state -- it's only to be used for specific components/use cases, not for everything.

@maya

maya commented May 31, 2016

Copy link
Copy Markdown
Contributor

These changes look good to me. Thanks again for your help, @joshbruce! 🎉

@maya maya merged commit fb35539 into uswds:staging May 31, 2016
@ducklet

ducklet commented Jun 1, 2016

Copy link
Copy Markdown

@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.

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.

5 participants