Skip to content

[menu] Close submenu on mouseout when parent opened on hover #1981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

michaldudak
Copy link
Member

When a menu is opened on hover, hovering out of the submenu now closes it.
It does not, however, close the whole tree, for two reasons:

  • It might be annoying to open a whole tree of menus and inadvertently close the whole thing by accidentally moving your mouse outside
  • Menus and submenus can be separated by a gap. When user wants to hover over the parent menu and moves the mouse over the gap, the whole menu would close. This could be avoided similarly to how "safe-polygon" is implemented for opening menus, but it would require quite complex custom logic.

Closes #1946

@michaldudak michaldudak requested a review from atomiks as a code owner May 28, 2025 13:55
@michaldudak michaldudak requested a review from colmtuite as a code owner May 28, 2025 13:55
@michaldudak michaldudak added the enhancement This is not a bug, nor a new feature label May 28, 2025
@michaldudak michaldudak changed the title [menu] Close submenu on moouseout when parent opened on hover [menu] Close submenu on mouseout when parent opened on hover May 28, 2025
Copy link

pkg-pr-new bot commented May 28, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@base-ui-components/react@1981

commit: 2fea9b6

Copy link

netlify bot commented May 28, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 2fea9b6
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/683715e0cc59150008ca163d
😎 Deploy Preview https://deploy-preview-1981--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.

@atomiks
Copy link
Contributor

atomiks commented Jun 2, 2025

It does not, however, close the whole tree, for two reasons:
It might be annoying to open a whole tree of menus and inadvertently close the whole thing by accidentally moving your mouse outside

This makes sense but also feels a bit confusing 🤔 I wonder if the current behavior is actually better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: menu enhancement This is not a bug, nor a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[menu] Close nested menus on mouseout when the root was open on hover
2 participants