Skip to content

[menu] do we need special behaviors and thus special markup for <button>s that invoke <menulist>s? #1468

Description

@dbaron

In whatwg/html#11729 (comment), whatwg/html#11729 (comment), whatwg/html#11729 (comment), and whatwg/html#11729 (comment) we had some discussion about what the pattern should be for <button> elements that open a <menulist>, in particular as a result of the changes from #1456. (I think it was mostly me and @lukewarlow though I think @scottaohara was also interested.)

The current state of the explainer following the changes for #1456 is that I've only made the small change from command=toggle-menu to command=toggle-popover so that the pattern for a <button> that opens a <menulist> is now:

<button command=toggle-popover commandfor=mymenu>
<menulist id=mymenu>
  ...menuitems go here...
</menulist>

or maybe even:

<button popovertarget=mymenu>
<menulist id=mymenu>
  ...menuitems go here...
</menulist>

I was thinking this was fine because buttons invoking menus didn't need any special behavior, and it would be fine if all of the special behavior were inside the <menulist> which is a popover.

One thing @mfreed7 asked me about yesterday is whether that's actually correct. In particular he suggested that we probably want to support the gesture involving:

  1. user mousedown on the <button>
  2. menu opens
  3. user moves mouse to a menuitem
  4. user mouseup on the menuitem activates it, including firing of click event (see [menu] Should an event be fired when a <menuitem> is selected? Which event? #1312)

This is a special behavior that isn't automatically implied by the above markup. And, in particular, the solution that the pointer events experts we've talked to so far are suggesting for #1312 is that we do event retargeting similar to what is done for the <label> element, which requires that we have an ancestor-or-self of the normal target of the click event (which is the nearest common ancestor of the mousedown element and the mouseup element). So if we want to do this we probably need a menu-specific element that contains both the <button> and the <menulist>. @mfreed7 suggested that <submenu> might be appropriate.

So I guess then the question is whether we should consider doing this. We could consider wrapping something like the above in a <submenu>... and then maybe also removing the markup above and making the <submenu> imply the invoking behavior just like it does for <menuitem>.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    menuMenu elements proposal

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions