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($theme-default): Make navbar dropdown links accessible #1837

Merged
merged 18 commits into from
Sep 15, 2019

Conversation

edisdev
Copy link
Contributor

@edisdev edisdev commented Sep 5, 2019

Summary

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Build-related changes
  • Other, please describe:

If changing the UI of default theme, please provide the before/after screenshot:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)

You have tested in the following browsers: (Providing a detailed version will be better.)

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE

Hi !
I've edited the accessibility of items on the navbar. (for this issue #1818 )

@edisdev edisdev changed the title #1818 | Make Accessibility Elements in navbar Refactoring: #1818 | Make Accessibility Elements in navbar Sep 5, 2019
@edisdev edisdev changed the title Refactoring: #1818 | Make Accessibility Elements in navbar ref: #1818 | Make Accessibility Elements in navbar Sep 5, 2019
@edisdev edisdev changed the title ref: #1818 | Make Accessibility Elements in navbar refactor: Make Accessibility Elements in navbar Sep 5, 2019
Copy link

@missmatsuko missmatsuko 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 getting into this! I added a couple notes re: accessibility.
Maybe adding the skip nav link should be a different issue/PR.
It's sort of related, but can be separate.

<ul class="nav-dropdown" style="display: none;" name="dropdown">
<li class="dropdown-item">
<!----> <a class="nav-link">Guide</a></li>
<!----> <a class="nav-link" tabindex="8">Guide</a></li>

Choose a reason for hiding this comment

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

We should try to avoid the use of positive values for tabindex if possible:
https://webaim.org/techniques/keyboard/tabindex

@@ -5,7 +5,9 @@
>
<a

Choose a reason for hiding this comment

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

The NavLink element should be only when it acts as a link (e.g. has a valid href value). If it's acting as a trigger to open a dropdown navigation, it should be a . This should probably remove the need to set an explicit tabindex ( without href is not focusable, but is focusable, at least on Chrome).

@@ -149,7 +160,8 @@ export default {
@media (min-width: $MQMobile)
.dropdown-wrapper
height 1.8rem
&:hover .nav-dropdown
&:hover .nav-dropdown,
&:focus-within .nav-dropdown

Choose a reason for hiding this comment

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

Opening the submenu on focus-within works ok, but it could be annoying if there's a navbar with many long submenus (i.e. you'd have to tab through every single item to get past the navbar). Adding a skip navigation link could help with that (and probably should also be added regardless), but a keyboard user would still have to tab through every submenu item on the way to the one they actually want.

The Adobe Mega Menu is a good example of the expected keyboard interactions and aria markup:

Copy link
Collaborator

Choose a reason for hiding this comment

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

thx for your explanation @missmatsuko

Copy link
Contributor Author

@edisdev edisdev Sep 8, 2019

Choose a reason for hiding this comment

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

@missmatsuko Thank you for comment and review :) You are right, Maybe it can make to focus submenus when key press the enter. Or, can be added focusable property to config file. and i will make tabindex="0" for focusable items . What do you think about this ?

Choose a reason for hiding this comment

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

I think there doesn't need to be an tabindex attribute at all. Can the link element be changed to a if it has children submenu items, and an anchor if it has an href?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made testing when I remove tabindex, element can not focusable in safari and firefox. @missmatsuko

@flozero flozero self-requested a review September 8, 2019 04:41
@flozero flozero added need feedback Awaiting author response type: enhancement Request to enhance an existing feature version: 1.x Relates to version 1 of VuePress labels Sep 8, 2019
@flozero flozero added the status: community assigned Community assigned label Sep 8, 2019
@missmatsuko
Copy link

missmatsuko commented Sep 9, 2019 via email

@edisdev
Copy link
Contributor Author

edisdev commented Sep 9, 2019

Unluckily, element has href property but it can not focusable. But as you say , can change dropdown open/close element with button. @missmatsuko

(Edit : This problem is due to the firefox version, likely. Thank you for support :) I will remove tabindex and make dropdown toggle element with button. should those with false properties still be given -1 tabindex to add a focusable property?)

Screen Shot 2019-09-09 at 16 24 33

Screen Shot 2019-09-09 at 16 22 44

Is it because the element is an with no href attribute set? The element should be focusable if this is changed to a element. A button is more appropriate here anyways because it isn't a link to a page - it should be used to open/close the submenu.

On Mon., Sep. 9, 2019, 12:04 a.m. Hatice Edis, @.> wrote: @.* commented on this pull request. ------------------------------ In @.***/theme-default/components/DropdownLink.vue <#1837 (comment)>: > @@ -149,7 +160,8 @@ export default { @media (min-width: $MQMobile) .dropdown-wrapper height 1.8rem - &:hover .nav-dropdown + &:hover .nav-dropdown, + &:focus-within .nav-dropdown I made testing when I remove tabindex, element can not focusable in safari and firefox. @missmatsuko https://github.com/missmatsuko — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#1837?email_source=notifications&email_token=AEIOIJSSLLG7P7FZAO4ZEUTQIXYRVA5CNFSM4IUCARBKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCEAYCGI#discussion_r322089822>, or mute the thread https://github.com/notifications/unsubscribe-auth/AEIOIJVWHRJKZEBD7RQ3GYDQIXYRVANCNFSM4IUCARBA .

@edisdev
Copy link
Contributor Author

edisdev commented Sep 9, 2019

What do you think about this ? @f3ltron

Unluckily, element has href property but it can not focusable. But as you say , can change dropdown open/close element with button. @missmatsuko

(Edit : This problem is due to the firefox version, likely. Thank you for support :) I will remove tabindex and make dropdown toggle element with button. should those with false properties still be given -1 tabindex to add a focusable property?)

Screen Shot 2019-09-09 at 16 24 33 Screen Shot 2019-09-09 at 16 22 44

Is it because the element is an with no href attribute set? The element should be focusable if this is changed to a element. A button is more appropriate here anyways because it isn't a link to a page - it should be used to open/close the submenu.

On Mon., Sep. 9, 2019, 12:04 a.m. Hatice Edis, @.> wrote: _@**._* commented on this pull request. ------------------------------ In _@_.*/theme-default/components/DropdownLink.vue <#1837 (comment)>: > @@ -149,7 +160,8 @@ export default { @media (min-width: $MQMobile) .dropdown-wrapper height 1.8rem - &:hover .nav-dropdown + &:hover .nav-dropdown, + &:focus-within .nav-dropdown I made testing when I remove tabindex, element can not focusable in safari and firefox. @missmatsuko https://github.com/missmatsuko — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#1837?email_source=notifications&email_token=AEIOIJSSLLG7P7FZAO4ZEUTQIXYRVA5CNFSM4IUCARBKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCEAYCGI#discussion_r322089822>, or mute the thread https://github.com/notifications/unsubscribe-auth/AEIOIJVWHRJKZEBD7RQ3GYDQIXYRVANCNFSM4IUCARBA .

@missmatsuko
Copy link

missmatsuko commented Sep 9, 2019

The anchor with javascript in the href should be a <button> element because it doesn't act as a link, it opens a submenu.
Link Behavior

Also sorry for breaking out of the thread, I didn't know replying by email would do that. 😬

@edisdev
Copy link
Contributor Author

edisdev commented Sep 9, 2019

No problem :) @missmatsuko As i said, I will turn the anchor a button element. I think, focusable property can be optional. As you said, if submenus has so many element, It may not be comfortable and useful.

@kefranabg kefranabg removed the need feedback Awaiting author response label Sep 10, 2019
@edisdev
Copy link
Contributor Author

edisdev commented Sep 10, 2019

Hi! @f3ltron @kefranabg . I did an new improvement, according last those described. I think pull request is ready of completely.

@flozero
Copy link
Collaborator

flozero commented Sep 10, 2019

@missmatsuko are you ok with changes ? As i am not so good with accessibility. I will try but i have no real idea if it's good or not

@missmatsuko
Copy link

I'm confused why notFocusable is a config setting. Nav items should just not be focusable if it's hidden (i.e. in a closed submenu).

@edisdev
Copy link
Contributor Author

edisdev commented Sep 13, 2019

@missmatsuko Thank you so much for your help 🤗😊🙏

@edisdev
Copy link
Contributor Author

edisdev commented Sep 13, 2019

Pr is approved :) @kefranabg

Looks good!

@kefranabg
Copy link
Collaborator

I'll do a review ASAP. Thanks for your work 💪

Copy link
Collaborator

@kefranabg kefranabg left a comment

Choose a reason for hiding this comment

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

Awesome work @edisdev 💪 I just made a few comments. Let me know if you have questions or want some help.

isTel
isTel,
keypressTab () {
this.$emit('keypressTab')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you rename this event keypress-tab. Other events names in the vuepress code uses - syntax.

},

computed: {
AllItemsCount () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be named with a lower-case a

@@ -65,12 +70,34 @@ export default {
props: {
item: {
required: true
},
dropdownName: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why using a props for the dropdown name? Why don't we just keep it as a local variable in the component? Btw I think we should consider a way to make this label customizable. The user might want to display different labels depending on the current selected language. This should be a default theme local. Could you add this feature and update the documentation?

</li>
</ul>

<NavLink
v-else
@keypressTab="focusoutDropdown(index + 1)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think that focusoutDropdown is a correct name for what the function is doing, right?

>
<NavLink :item="childSubItem"/>
<NavLink
@keypressTab="focusoutDropdown((index + 2) * (subIndex + 1))"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand the + 2? Could you explain? Why not just + 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry, There was a bug here. I resolved this. 👍

@kefranabg
Copy link
Collaborator

I also found a bug:

The dropdown will immediately close when the last child element of it is focused

@edisdev
Copy link
Contributor Author

edisdev commented Sep 15, 2019

Hi @kefranabg :) Thank you so much review, i resolved your comments :) And also i fixed your said bug. 👍

@@ -54,6 +54,7 @@ export default {
const themeLocales = this.$site.themeConfig.locales || {}
const languageDropdown = {
text: this.$themeLocaleConfig.selectText || 'Languages',
ariaLabel: this.$themeLocaleConfig.ariaLabel || 'Languages',
Copy link
Collaborator

Choose a reason for hiding this comment

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

The default value should be Select language

@@ -39,6 +39,7 @@ module.exports = ctx => ({
'/': {
label: 'English',
selectText: 'Languages',
ariaLabel: "Languages",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The value should be Select language

methods: {
toggle () {
this.open = !this.open
},

getSubItemIndex (index, subIndex) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This part is kind of hard to read/understand, I'll try to find something easier for this part

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I too will try to find to a more easy solution.

@kefranabg
Copy link
Collaborator

We should also add a example for aria-label in this documentation page

@edisdev
Copy link
Contributor Author

edisdev commented Sep 15, 2019

@kefranabg i will resolve immediately your comments. 👍

@edisdev
Copy link
Contributor Author

edisdev commented Sep 15, 2019

@kefranabg I added a example for aria-label in documentation page . But, i could not write description for Chinese example, because i don't know Chinese. :(

@@ -72,6 +72,25 @@ module.exports = {
}
```

You can change `aria-label` of dropdown button to with a custom aria-label. Default value is text property. if the dropdown menu consists of language items., default value is 'Select language'
Copy link
Collaborator

@kefranabg kefranabg Sep 15, 2019

Choose a reason for hiding this comment

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

I don't think we need an entire section for aria-label 😉 What I meant was just adding ariaLabel: 'Language Menu' in existing examples in this page. And I think you can do the same for Chineese. Sorry I wasn't clear about this 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okey, i wil add that in existing examples :)

@kefranabg
Copy link
Collaborator

@edisdev You'll find my proposition in the last commit to simplify the close dropdown algorithm. What do you think?

@edisdev
Copy link
Contributor Author

edisdev commented Sep 15, 2019

I think code is more readable and clear now :) Thank you :)

@edisdev You'll find my proposition in the last commit to simplify the close dropdown algorithm. What do you think?

Copy link
Collaborator

@kefranabg kefranabg left a comment

Choose a reason for hiding this comment

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

Thanks again!

@edisdev
Copy link
Contributor Author

edisdev commented Sep 15, 2019

Thank you so much too :) @kefranabg

@kefranabg kefranabg changed the title refactor: Make Accessibility Elements in navbar fix($theme-default): Make navbar dropdown links accessible Sep 15, 2019
@kefranabg kefranabg merged commit a8ce645 into vuejs:master Sep 15, 2019
@vue-bot
Copy link

vue-bot commented Sep 15, 2019

Thanks again! 💚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: community assigned Community assigned type: enhancement Request to enhance an existing feature version: 1.x Relates to version 1 of VuePress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants