-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Conversation
There was a problem hiding this 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> |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Is it because the element is an <a> with no href attribute set? The element
should be focusable if this is changed to a <button> 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>
.
|
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?)
|
What do you think about this ? @f3ltron
|
The anchor with javascript in the href should be a Also sorry for breaking out of the thread, I didn't know replying by email would do that. 😬 |
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. |
Hi! @f3ltron @kefranabg . I did an new improvement, according last those described. I think pull request is ready of completely. |
@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 |
I'm confused why |
@missmatsuko Thank you so much for your help 🤗😊🙏 |
Pr is approved :) @kefranabg
|
I'll do a review ASAP. Thanks for your work 💪 |
There was a problem hiding this 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') |
There was a problem hiding this comment.
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 () { |
There was a problem hiding this comment.
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: { |
There was a problem hiding this comment.
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)" |
There was a problem hiding this comment.
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))" |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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. 👍
I also found a bug: The dropdown will immediately close when the last child element of it is focused |
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', |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
We should also add a example for |
@kefranabg i will resolve immediately your comments. 👍 |
@kefranabg I added a example for |
@@ -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' |
There was a problem hiding this comment.
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 😛
There was a problem hiding this comment.
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 :)
@edisdev You'll find my proposition in the last commit to simplify the close dropdown algorithm. What do you think? |
I think code is more readable and clear now :) Thank you :)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again!
Thank you so much too :) @kefranabg |
Thanks again! 💚 |
Summary
What kind of change does this PR introduce? (check at least one)
If changing the UI of default theme, please provide the before/after screenshot:
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
fix #xxx[,#xxx]
, where "xxx" is the issue number)You have tested in the following browsers: (Providing a detailed version will be better.)
Hi !
I've edited the accessibility of items on the navbar. (for this issue #1818 )