Skip to content

[context menu] Ignore context menu mouseup on non-Mac platforms#3944

Merged
atomiks merged 5 commits intomui:masterfrom
atomiks:codex/issue-3595-context-menu-mouseup
Feb 13, 2026
Merged

[context menu] Ignore context menu mouseup on non-Mac platforms#3944
atomiks merged 5 commits intomui:masterfrom
atomiks:codex/issue-3595-context-menu-mouseup

Conversation

@atomiks
Copy link
Copy Markdown
Contributor

@atomiks atomiks commented Feb 3, 2026

Fixes #3595

On Mac, context menus open on mousedown so they support the down -> move -> release up pattern for selection. On Windows it opens on mouseup, so that's irrelevant. I don't know about Linux, but I've just made it match Windows for simplicity.

@atomiks atomiks added type: bug It doesn't behave as expected. component: context menu Changes related to the context menu component. platform: windows labels Feb 3, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 3, 2026

commit: aea36a2

@mui-bot
Copy link
Copy Markdown

mui-bot commented Feb 3, 2026

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+22B(0.00%) 🔺+2B(0.00%)

Details of bundle changes


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

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 3, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit aea36a2
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/698ed8a6f91ae60008da700b
😎 Deploy Preview https://deploy-preview-3944--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 February 3, 2026 07:52
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 3, 2026

Greptile Overview

Greptile Summary

This PR changes context-menu item mouseup handling to ignore right-click mouseup on non‑Mac platforms (matching Windows behavior), and updates tests by removing mouseup-driven closing scenarios while keeping coverage for ignoring mouseup at the initial spawn point.

The behavioral change lives in the shared menu-item hook (useMenuItemCommonProps), so it affects all menu item types used under ContextMenu roots, preventing unintended item activation/closure on Windows/Linux-style context menu interactions.

Confidence Score: 4/5

  • This PR is reasonably safe to merge, with low functional risk confined to context-menu mouseup behavior.
  • The change is small and scoped to a single event handler branch, and existing tests still cover the core “ignore mouseup at spawn point” regression. Main remaining risk is environment brittleness if detectBrowser reads browser globals at import time, which could impact SSR or non-browser tests.
  • packages/react/src/menu/item/useMenuItemCommonProps.ts

Important Files Changed

Filename Overview
packages/react/src/menu/item/useMenuItemCommonProps.ts Adds a non-Mac guard to ignore right-click mouseup for context menus; potential brittleness if isMac touches browser globals at import time.
packages/react/src/context-menu/root/ContextMenuRoot.test.tsx Removes mouseup-driven close tests and keeps tests for ignoring mouseup at spawn point; coverage for non-Mac behavior is reduced.

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread packages/react/src/menu/item/useMenuItemCommonProps.ts
import { createRenderer, isJSDOM } from '#test-utils';
import { REASONS } from '../../utils/reasons';

vi.mock('@base-ui/utils/detectBrowser', async () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's add a test for non-Mac environment, just to be safe.

Comment thread packages/react/src/menu/item/useMenuItemCommonProps.ts
Copy link
Copy Markdown
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

LGTM. 👍
Maybe @flaviendelangle could check the behavior on Linux?

@flaviendelangle
Copy link
Copy Markdown
Member

When a context menu is open, right-clicking on an item inside the context menu immediately closes the menu instead of allowing the item to handle the right-click interaction.

If this is the bug, then I can't reproduce it on master and on this PR (Linux Mint - Chromium).

Copy link
Copy Markdown
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

Looks OK on Windows.

@atomiks atomiks merged commit d1f55d8 into mui:master Feb 13, 2026
22 of 23 checks passed
@atomiks atomiks deleted the codex/issue-3595-context-menu-mouseup branch February 13, 2026 07:58
@LukasTy
Copy link
Copy Markdown
Member

LukasTy commented Feb 13, 2026

When a context menu is open, right-clicking on an item inside the context menu immediately closes the menu instead of allowing the item to handle the right-click interaction.

If this is the bug, then I can't reproduce it on master and on this PR (Linux Mint - Chromium).

Thank you for checking. 🙏
Yes, and it looks like it was/is only reproducible on Windows. 👌

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

Labels

component: context menu Changes related to the context menu component. platform: windows type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[context menu] Context menu closes when right-clicking a menu item on Windows

6 participants