Skip to content

Conversation

@domfarolino
Copy link
Member

@domfarolino domfarolino commented Dec 11, 2025

This PR introduces the <menubar>, <menulist>, and <menuitem> elements as they appear in Open UI's menu elements proposal: https://open-ui.org/components/menu.explainer/. This includes their integration with popovers, command invokers, <fieldset> and checkability, default styles, and variant default styles for the <menulist> element depending on how it is rendered. What has not been spec'd yet is:

  • Anchor positioning fallback styles
  • The orientation attribute's effect on default styles and keyboard navigability
  • Exact keyboard behavior; we plan to follow customizable select's precedent (see [select] keyboard behavior openui/open-ui#1087) of specifying activation behavior, and what happens when you keyboard-navigate away from a menu item (i.e., dismissing <menulist> popovers). But to be consistent with customizable select, we're not planning on specifying the exact keyboard behavior for getting from one menulist to another in a menubar, or traversing through menu items in a menu bar or list. These will be covered by examples, notes, and .optional WPTs
  • The checked event integration discussed in What event should fire on checkable menu items? openui/open-ui#1321
  • Figuring out how/if we need to express keyboard type-ahead search (i.e., pressing the a key to focus the first menuitem in a menulist that starts with the character a)
  • ...

This PR is only a draft. It's suitable for stage 2 evaluation of the menu elements proposal tracked by #11729, but has rough edges and non-trivial TODOs. The API shape is just about fully expressed though.

(See WHATWG Working Mode: Changes for more details.)


/dom.html ( diff )
/form-elements.html ( diff )
/grouping-content.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/infrastructure.html ( diff )
/interaction.html ( diff )
/interactive-elements.html ( diff )
/obsolete.html ( diff )
/popover.html ( diff )
/rendering.html ( diff )
/semantics-other.html ( diff )

Note there are a couple open questions in the form of TODOs. For example:

1. Should `popovertargetaction` be allowed to target `<menulist>` elements?
   Probably, but it could use discussion.
2. Should the attribute change steps that react to `popover` attribute
   mutations "work" on `<menulist>` elements? This effectively makes the
   explicit `popover` attribute work on `<menulist>` elements, possibly
   overriding their default popover behavior. This could also use more
   discussion. (My preference would be to ignore `popover` on `<menulist>`
   for now).
This commit moves the command/commandfor attributes into their own section,
since they're general to both buttons and menuitem elements. The next steps are:

 1. Pull out a shared activation behavior algorithm from the button element,
 that defines the command-invoking parts that the two elements have in common
 2. Add the three new commands
 3. Define the menuitem element, and any menuitem-specific things for the
    commands
These are copied from the main button activation steps's popover handling steps
@domfarolino domfarolino added the agenda+ To be discussed at a triage meeting label Dec 11, 2025
<p><dfn><code>menuitem</code> element inner content elements</dfn> are the elements which are
allowed as descendants of <code>menuitem</code> elements.</p>

<p>The following are <span><code>option</code> element inner content elements</span>:</p>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<span><code>option</code>

<span><code>menuitem</code>

<dt><span data-x="concept-element-contexts">Contexts in which this element can be used</span>:</dt>
<dd>Where <span>flow content</span> is expected.</dd>
<dt><span data-x="concept-element-content-model">Content model</span>:</dt>
<dd>Zero or more <code>menuitem</code> elements.</dd>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zero or more menuitem elements.

Zero or more menulist element inner content elements.

<dt><span data-x="concept-element-content-model">Content model</span>:</dt>
<dd>Zero or <span><code>menuitem</code> element inner content elements</span>.</dd>
<dt><span data-x="concept-element-attributes">Content attributes</span>:</dt>
<dd><span>Global attributes</span></dd>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "command" & "commandfor" attribute should be added .

<dl class="element">
<dt><span data-x="concept-element-categories">Categories</span>:</dt>
<dd><span><code>menulist</code> element inner content elements</span>.</dd>
<dd>If the element's children include at least one <code>menuitem</code> element: <span>Palpable content</span>.</dd>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can menuitem element be placed inside menuitem element?

<dd>As a descendant of a <code>menubar</code> element.</dd>
<dd>As a descendant of a <code>menulist</code> element.</dd>
<dt><span data-x="concept-element-content-model">Content model</span>:</dt>
<dd>Zero or <span><code>menuitem</code> element inner content elements</span>.</dd>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<dd>Zero or <span>

<dd>Zero or more <span>

padding-block: 0;
padding-inline: 0;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it seems necessary to add CSS of "menulist > fieldset > legend".

@mtrootyy
Copy link

The menubar element & the menulist element is "Interactive content"?

The menubar element & the menulist element should be added to section of "3.2.5.2.2 Flow content" & "3.2.5.2.8 Palpable content".

In section of "4.4.19 The div element";

  • The "menuitem element inner content elements" should be added to "Categories:".
  • The "Otherwise, if the element is a descendant of an menuitem element: Zero or more menuitem element inner content elements." should be added to "Content model:".

In section of "4.10.15 The fieldset element";

  • The "menulist element inner content elements" should be added to "Categories:".
  • "Content model:" of "if the element is a descendant of a menulist element" should be clarified.

In section of "4.4.2 The hr element";

  • The "menulist element inner content elements" should be added to "Categories:".

The section of "15.3.12 The fieldset and legend elements" also apply to fieldset & legend elements who is descendant of a menulist element?

@mtrootyy
Copy link

In section of "4.4.10 The menuitem element";
The following sentence shoud be added as firest sentence of prose.

The menuitem element represents command that the user can invoke, or a sub-menu that the user can trigger.
The menuitem element constitute contents of a menubar element or a menulist element.

In section of "4.4.2 The hr element";

The hr element represents a paragraph-level thematic break, e.g., a scene change in a story, or a transition to another topic within a section of a reference book; alternatively, it represents a separator between a set of options of a select element.

  ↓should change

The hr element represents a paragraph-level thematic break, e.g., a scene change in a story, or a transition to another topic within a section of a reference book; alternatively, it represents a separator between a set of options of a select element; alternatively, it represents a separator between a set of menuitem elements in a menulist element.

In section of "4.10.15 The fieldset element";

The fieldset element represents a set of form controls (or other content) grouped together, optionally with a caption. The caption is given by the first legend element that is a child of the fieldset element, if any. The remainder of the descendants form the group.

  ↓should change

The fieldset element represents a set of form controls (or other content) grouped together, optionally with a caption. The caption is given by the first legend element that is a child of the fieldset element, if any. The remainder of the descendants form the group.
Alternatively, it represents a set of menuitem elements in a menulist element.The label is given by the first legend element that is a child of the fieldset element, if any. 

}

menulist {
display: flex;
Copy link

@mtrootyy mtrootyy Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the menulist element is exactly a "native" popover, shouldn't the default of initial state of the menulist element be "display:none"?

At least, the following should be added.

menulist:not(:popover-open) {
  display:none;
}

@mtrootyy
Copy link

In section of "4.10.16 The legend element";

  • "Content model:" of "if the element is a descendant of a menulist element" should be clarified.

border-radius: 0.25em;
padding: 0.25em;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following should be added;

menubar[orientation="vertical"]  {
  flex-direction: column;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agenda+ To be discussed at a triage meeting

Development

Successfully merging this pull request may close these issues.

3 participants