You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation uses <vaadin-list-box role="list"> which is semantically incorrect if we wish to build a menu. The role should be set to "menu" and the items should have role="menuitem".
(Ideally aria-haspopup, aria-controls and aria-expanded should also exist on the element that triggers the popup.)
The semantics change a bit depending on the menu type. Some examples below...
While this technically works VoiceOver will announce "Home, menu item" instead of "Home, link". The latter is more accessible IMO. We should be careful in recommending this approach over the established usage of <nav>, <ul>, <li> and <a>.
Prototyping
Tested a few approaches and found that putting the attributes (role and aria-checked) on <vaadin-context-menu> and <vaadin-context-menu-item> produces a result that's fairly close to the native HTML approach.
web-padawan
changed the title
[context-menu] a11y semantics
[context-menu] Update role attribute on checkable items to use menuitemcheckboxJan 30, 2023
The current implementation uses
<vaadin-list-box role="list">
which is semantically incorrect if we wish to build a menu. The role should be set to"menu"
and the items should haverole="menuitem"
.(Ideally
aria-haspopup
,aria-controls
andaria-expanded
should also exist on the element that triggers the popup.)The semantics change a bit depending on the menu type. Some examples below...
Example 1: Application Menus
It's important to note that elements with
role="menuitem"
should not contain interactive content.Example 2: Text Style
Allows multiple items to be selected.
Example 3: Font Selection
Should only allow one selection.
Example 4: Navigation
While this technically works VoiceOver will announce "Home, menu item" instead of "Home, link". The latter is more accessible IMO. We should be careful in recommending this approach over the established usage of
<nav>
,<ul>
,<li>
and<a>
.Prototyping
Tested a few approaches and found that putting the attributes (
role
andaria-checked
) on<vaadin-context-menu>
and<vaadin-context-menu-item>
produces a result that's fairly close to the native HTML approach.Tested in Chrome and Safari with VoiceOver.
The text was updated successfully, but these errors were encountered: