open-ui icon indicating copy to clipboard operation
open-ui copied to clipboard

[menu] Activation behavior for opening submenus

Open josepharhar opened this issue 10 months ago • 5 comments

If a menuitem is hooked up to open a submenu:

  1. Should hovering or clicking invoke the submenu? Should it be developer controllable?
  2. Should keyboard focus open the submenu, or should you have to focus and then press another keyboard button to open the submenu?
  • Where should keyboard focus go when the submenu is invoked?

Does interesttarget already have answers to all of these questions? If so, how could we ergonomically combine interesttarget with however we hook up the association between a menuitem and submenu?

josepharhar avatar Apr 10 '25 14:04 josepharhar

Right now this seems to be very much "it depends". There's not a clear consensus across the implementations I've seen.

Selfishly I think the macOS approach is good, because it's what I know. It might also marginally make it easier to spec. Though possibly like with select we can make this UA defined (I would prefer to specify though).

lukewarlow avatar Apr 10 '25 15:04 lukewarlow

I guess for an initial draft. We could just verbatim go with https://www.w3.org/WAI/ARIA/apg/patterns/menubar/ and then we can discuss specific changes to that where desired?

lukewarlow avatar Apr 10 '25 15:04 lukewarlow

Should hovering or clicking invoke the submenu? Should it be developer controllable?

probably developer controllable. the menuitems of menubars commonly require specific action for a user to invoke them - but menuitems that invoke submenus within a menu popup and often automatically show their related submenus on hover/focus or still require someone to invoke them via purposeful activation (click even).

so mabye click to open is the default, and then authors can change to open on hover/focus to match their current custom implementations.

Should keyboard focus open the submenu, or should you have to focus and then press another keyboard button to open the submenu?

answered this above. it could be either.

Where should keyboard focus go when the submenu is invoked?

if opened via click, then auto-moving to the appropriate menuitem in the submenu can be reasonable. but would not be desired if the submenu auto opened on focus/hover

scottaohara avatar Apr 10 '25 19:04 scottaohara

FWIW, the submenu activation should follow what the platform defaults are with a pointer device. I.E. Open on hover.

This unfortunately can become cumbersome as with touch-inputs with split-submenu buttons and touch devices where you don't necessarily have the option to "hover". (E: There could be a possibility to add an affordance to the split-submenu scenarios for touch screen devices to have an extra state for touch devices where you have to activate the sub-menu a second time when using a touch device)

And like with the new styleable select element, we should keep the platform functionality of drag-clicking to navigate the menu and invoke the selected option.

Related Issues: https://github.com/openui/open-ui/issues/1113 https://github.com/whatwg/html/issues/10762

Permik avatar Jun 11 '25 17:06 Permik