Description
HTML does not allow nested interactive elements.
I have seen a similar discussion here, which discusses how nested interactive roles are a problem for screenreader users.
I would like to understand how to go about creating a widget which has nested interactive elements. Since semantic HTML can't be used to create these nested interactions, how would we expose the correct ARIA roles so that it is still screenreader and keyboard friendly.
Some examples:
The above image shows a widget used by gmail. The widget is interactive as a whole, but once you hover on it, an overflow menu is also available which is also interactive.
The overflow menu is created using a div, the trigger for this overflow menu has aria-popup.
The widget is created using a div, which passes on the keyboard interactions to the underlying link, and once the focus is on this widget, user can press tab to focus the overflow menu.
I would like to understand if there are some guidelines for nested interactivity in ARIA, with or without a dependency on semantic HTML.
Is it fine to have nested interactive elements as long as it is valid HTML/valid aria structure?
so button
inside button
or role="button"
inside role="button"
wouldn't be allowed, but if we just replace it with div
inside div
(and take care of the keyboard interactions) it would be fine ?
If nested interactions are not a problem as such, any pointers to why they are not allowed in HTML?