Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.

Enable keyboard interaction for nav toggles #106

Merged
merged 2 commits into from
Apr 29, 2020
Merged

Enable keyboard interaction for nav toggles #106

merged 2 commits into from
Apr 29, 2020

Conversation

ccardinaux
Copy link
Contributor

@ccardinaux ccardinaux commented Apr 23, 2020

Should fix #53

  • Changes <h4> to <button> in navigation toggles
  • Adds aria-expanded and aria-controls attributes to navigation toggles
  • Adds an id to collection item containers to link to aria-controls

@@ -63,6 +63,7 @@ class TreeCollection {
this._tree = tree;
this._el = $(el);
this._toggle = this._el.find('> [data-role="toggle"]');
this._toggleBtn = this._toggle.find('button');
Copy link
Member

Choose a reason for hiding this comment

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

i think it's weird that the actual clickable element is the h4, not the button. it would make more sense to move the data-role attribute to the button and use the button's focus etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense - ended up removing the h4 entirely to simplify styling

@@ -43,14 +43,25 @@
background-color: $color-ui-hover;
}

span {
&:focus-within {
Copy link
Member

Choose a reason for hiding this comment

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

this is not supported in some older browsers that we should support with our browserslist config (which we don't actually have, since we use the default config)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, no longer relying on this

@@ -14,9 +14,9 @@
{% if item.isCollection or (item.isComponent and not item.isCollated and item.variants().filter('isHidden', false).size > 1) %}
<li class="Tree-item Tree-collection Tree-depth-{{ depth }}" data-behaviour="collection" id="tree-{{ root.name }}-collection-{{ item.handle }}">
<h4 class="Tree-collectionLabel" data-role="toggle">
<span>{{ item.label }}</span>
<button aria-expanded="false" aria-controls="tree-{{ root.name }}-collection-{{ item.handle }}-items">{{ item.label }}</button>
Copy link
Member

Choose a reason for hiding this comment

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

the aria-expanded="false" attribute is wrong i think since the collections are closed with js on page load, so this should default to true here and be switched when the collection is closed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense!

@ccardinaux
Copy link
Contributor Author

Thanks for the feedback @Risker!

@ccardinaux ccardinaux closed this Apr 28, 2020
@ccardinaux ccardinaux reopened this Apr 28, 2020
@ccardinaux ccardinaux requested a review from mihkeleidast April 28, 2020 23:28
@mihkeleidast mihkeleidast merged commit af013ab into frctl:master Apr 29, 2020
@mihkeleidast
Copy link
Member

Thank you!

@ccardinaux ccardinaux deleted the keyboard-navigation branch April 29, 2020 17:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Toggles in the navigation are not keyboard accessible
3 participants