Skip to content

[navigation menu] Add openOnHover and closeOnClick props #2278

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 4 commits into
base: master
Choose a base branch
from

Conversation

atomiks
Copy link
Contributor

@atomiks atomiks commented Jul 9, 2025

Adds two props:

  • openOnHover to NavigationMenu.Item allows disabling the hover-to-open behavior for individual items/triggers
  • closeOnClick to NavigationMenu.Link closes the popup by default when clicking a link, useful when it's in a shared layout across the links, defaulting to uncontrolled behavior

Closes #2254

Copy link

pkg-pr-new bot commented Jul 9, 2025

vite-css-base-ui-example

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

commit: 8fc552c

@mui-bot
Copy link

mui-bot commented Jul 9, 2025

Bundle size report

Bundle Parsed Size Gzip Size
@base-ui-components/react 🔺+225B(+0.07%) 🔺+31B(+0.03%)

Details of bundle changes

Generated by 🚫 dangerJS against 8fc552c

Copy link

netlify bot commented Jul 9, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 8fc552c
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/686e3fa5fbe57a0008f94fcc
😎 Deploy Preview https://deploy-preview-2278--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 atomiks marked this pull request as ready for review July 9, 2025 04:45
@michaldudak
Copy link
Member

When an item has openOnHover = false, it can still be opened on hover after another item is opened. This seems OK, but the popup doesn't close on mouseout (it behaves as it was open by clicking).

@atomiks
Copy link
Contributor Author

atomiks commented Jul 9, 2025

This seems OK

This seems unexpected to me; I've changed it so it closes instead when mousing out of the openOnHover trigger

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

Successfully merging this pull request may close these issues.

[Navigation Menu] Support click-only or mixed trigger modes for item activation
3 participants