web-components icon indicating copy to clipboard operation
web-components copied to clipboard

[menu-bar] Add possibility to disable roving tabindex

Open juuso-vaadin opened this issue 2 years ago • 5 comments

Describe your motivation

MenuBar is sometimes used with styling that makes MenuItems appear as separate Buttons. Especially in this case the expected focus behavior would be to move focus between MenuItems with TAB key instead of arrow keys.

image

Currently custom styling can be applied and buttons can be made focusable separately by forcing the tabindex="0" on MenuItems with custom JS. This breaks has proven not to be perfect solution as the tooltips don't work as expected.

Describe the solution you'd like

Built-in theme variant for separated MenuItems and option to disable roving tabindex.

Describe alternatives you've considered

Using a layout with Buttons instead of MenuBar would sacrifice the overflowing behavior. Creating a "dropdown button" could still be done as single item MenuBar but it would be bit more complex to write.

Current focus indicator doesn't visually communicate that there is roving tabindex pattern within the component. Alternative could be to draw a focus-ring around the whole MenuBar in addition to focused MenuItem to better indicate this behaviour.

Additional context

It is known that according to accessibility guidelines roving tabindex should be used for MenuBar. Here the intent is to "misuse" MenuBar to get the overflow functionality and therefore deviating from a11y guidelines could be justified.

juuso-vaadin avatar Nov 01 '23 19:11 juuso-vaadin

Here the intent is to "misuse" MenuBar to get the overflow functionality and therefore deviating from a11y guidelines could be justified.

We should probably remove role=menubar and convert from role=menuitem to role=button on the root level.

jouni avatar Nov 02 '23 09:11 jouni

Yup, aria-roles need to be adjusted accordingly then as well. (Not sure what role the bar-root should have in this case, possibly toolbar?)

I suppose an alternative would be to introduce a separate "button group" or "toolbar" component. Something along those lines is discussed in https://github.com/vaadin/web-components/issues/4206 and https://github.com/vaadin/web-components/issues/934

rolfsmeds avatar Nov 02 '23 10:11 rolfsmeds

Not sure what role the bar-root should have in this case, possibly toolbar?

Nope.

Screenshot 2023-11-02 at 13 02 51

jouni avatar Nov 02 '23 11:11 jouni

Right, then I suppose it'll just have to be role="group", which means that it might be tricky to get aria-labels announced on it, but it is what it is.

rolfsmeds avatar Nov 02 '23 12:11 rolfsmeds

Acceptance Criteria: https://github.com/vaadin/platform/issues/6552

rolfsmeds avatar Jun 28 '24 14:06 rolfsmeds