-
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
Changes from 6 commits
311f11f
44462b6
3593b4b
e996d18
510be5b
380911d
fd30a60
8bd733f
1b38f36
a5a66f1
0a27789
96b1287
c67010e
e84b6c6
6da2e5f
842157d
371af79
0ef66cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`DropdownLink renders dropdown link. 1`] = ` | ||
<div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">VuePress</span> <span class="arrow right"></span></a> | ||
<div class="dropdown-wrapper"><a aria-label="Languages" tabindex="8" class="dropdown-title"><span class="title">VuePress</span> <span class="arrow right"></span></a> | ||
<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> | ||
<li class="dropdown-item"> | ||
<!----> <a class="nav-link">Config Reference</a></li> | ||
<!----> <a class="nav-link" tabindex="8">Config Reference</a></li> | ||
</ul> | ||
</div> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,9 @@ | |
> | ||
<a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
class="dropdown-title" | ||
:aria-label="dropdownName" | ||
@click="toggle" | ||
:tabindex="tabIndex" | ||
> | ||
<span class="title">{{ item.text }}</span> | ||
<span | ||
|
@@ -35,12 +37,13 @@ | |
:key="childSubItem.link" | ||
v-for="childSubItem in subItem.items" | ||
> | ||
<NavLink :item="childSubItem"/> | ||
<NavLink :tabindex="tabIndex" :item="childSubItem"/> | ||
</li> | ||
</ul> | ||
|
||
<NavLink | ||
v-else | ||
:tabindex="tabIndex" | ||
:item="subItem" | ||
/> | ||
</li> | ||
|
@@ -65,6 +68,14 @@ export default { | |
props: { | ||
item: { | ||
required: true | ||
}, | ||
dropdownName: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
default: 'Dropdown', | ||
type: String | ||
}, | ||
tabIndex: { | ||
default: 0, | ||
type: Number | ||
} | ||
}, | ||
|
||
|
@@ -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 commentThe 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 commentThe 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 commentThe 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 commentThe 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 commentThe 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 |
||
// override the inline style. | ||
display block !important | ||
.dropdown-title .arrow | ||
|
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