Skip to content

Conversation

@michaldudak
Copy link
Member

@michaldudak michaldudak commented Nov 7, 2025

Implemented detached / multiple trigger support in Menu, similarly to #2336

It is now possible to define triggers outside of Menu.Root using the handle prop. Multiple triggers per menu with a dynamic payload are also implemented.

Detached triggers also work in Menubar menus.

Content transitions will be implemented in a follow-up PR.

Closes #3031

Preview

Breaking changes

  • openOnHover, delay, and closeDelay props moved from Menu.Root to Menu.Trigger.
  • Menus must have at least one trigger.

@michaldudak michaldudak added component: menu Changes related to the menu component. type: new feature Expand the scope of the product to solve a new problem. breaking change Introduces changes that are not backward compatible. labels Nov 7, 2025
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 7, 2025
@mui-bot
Copy link

mui-bot commented Nov 7, 2025

Bundle size report

Bundle Parsed size Gzip size
@base-ui-components/react 🔺+12.1KB(+3.07%) 🔺+3.39KB(+2.70%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify
Copy link

netlify bot commented Nov 7, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit a90cbf8
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6915d8ada6bca500080ef66e
😎 Deploy Preview https://deploy-preview-3170--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@michaldudak michaldudak force-pushed the menu-detached-triggers branch from 9b462ac to 916dbd9 Compare November 9, 2025 09:32
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 9, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 9, 2025

vite-css-base-ui-example

pnpm add https://pkg.pr.new/mui/base-ui/@base-ui-components/react@3170
pnpm add https://pkg.pr.new/mui/base-ui/@base-ui-components/utils@3170

commit: a90cbf8

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 10, 2025
@michaldudak michaldudak force-pushed the menu-detached-triggers branch from 50d12bd to 4ff5a85 Compare November 10, 2025 09:20
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 10, 2025
@michaldudak michaldudak force-pushed the menu-detached-triggers branch from 4ff5a85 to da41ab9 Compare November 10, 2025 09:24
@atomiks
Copy link
Contributor

atomiks commented Nov 11, 2025

This is also on main, but not in beta.4, perhaps it should be fixed here though:

On https://deploy-preview-3170--base-ui.netlify.app/experiments/popups/popups-in-popups, click-to-drag on the menu to a submenu item and releasing closes the dialog unexpectedly

@michaldudak michaldudak marked this pull request as ready for review November 11, 2025 13:56
@atomiks
Copy link
Contributor

atomiks commented Nov 12, 2025

On https://deploy-preview-3170--base-ui.netlify.app/experiments/menu/nested-detached-triggers,

  • When a submenu is open, trying to hover a new menubar trigger doesn't work. (Works fine on the Menubar docs hero demo, though)
  • When clicking the first trigger, then hovering to the last trigger, hovering over and out of the menu, it closes unexpectedly. Afterwards, clicking a trigger causes it to close on pointerup.

@atomiks
Copy link
Contributor

atomiks commented Nov 12, 2025

  • Tabbing out of the menu in the controlled section of the experiment skips over the other triggers
  • Pressing Esc instantly returns focus instead of waiting for unmount

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 12, 2025

return React.useMemo(() => (enabled ? { reference } : {}), [enabled, reference]);
return React.useMemo(
() => (enabled ? { reference, trigger: reference } : {}),
Copy link
Member

Choose a reason for hiding this comment

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

What's the value of adding the trigger as key, if it's always the same as the reference value?

Copy link
Member Author

Choose a reason for hiding this comment

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

useInteractions returns methods like getReferenceProps and getTriggerProps that use these keys. MenuTrigger calls these methods depending on whether it's an active trigger. Previously, nothing would be returned in the getTriggerProps call.

);
}

function ReusableMenu(props: { handle: Menu.Handle<ContentKey> }) {
Copy link
Member

Choose a reason for hiding this comment

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

I really like the API, it's very clean 👌

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 12, 2025
@atomiks
Copy link
Contributor

atomiks commented Nov 13, 2025

In the Menubar experiment, the safe polygon logic broke on the 'Add to playlist' submenu

@mnajdova
Copy link
Member

Another bug I noticed in the Menubar is that if I open a submenu, the other menus no longer open on hover. There is also a flicker if I try to reopen the same submenu, see the recording attached.

Screen.Recording.2025-11-13.at.09.11.18.mov

@michaldudak michaldudak force-pushed the menu-detached-triggers branch from 303c29f to 7969c67 Compare November 13, 2025 09:31
@michaldudak michaldudak force-pushed the menu-detached-triggers branch from bc0b301 to e34b1bb Compare November 13, 2025 11:04
Copy link
Contributor

@atomiks atomiks left a comment

Choose a reason for hiding this comment

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

Haven't been able to find regressions in regular menus - in the docs, some of the components need to be updated to use the tag format <Menu.Root> (not Menu.Root)

@michaldudak michaldudak merged commit d894615 into mui:master Nov 13, 2025
20 checks passed
@michaldudak michaldudak deleted the menu-detached-triggers branch November 13, 2025 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Introduces changes that are not backward compatible. component: menu Changes related to the menu component. type: new feature Expand the scope of the product to solve a new problem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[menu] Support detached triggers

4 participants