-
-
Notifications
You must be signed in to change notification settings - Fork 321
[menu] Add pressMode option to the MenuTrigger
#3634
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
base: master
Are you sure you want to change the base?
Conversation
commit: |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
a3d0917 to
096107d
Compare
# Conflicts: # packages/react/src/menu/trigger/MenuTrigger.tsx
096107d to
81ab430
Compare
|
Can we for starter create a demo for this? To see how it looks in user-land and then decide if we want to have it as a feature directly in the component. |
|
@mnajdova Thanks for taking a look! Sure, I can add a demo later. In the meantime, the CodeSandbox I shared already includes this. Although it is very rough, please refer to the "AFTER" section to see how it looks. |
This PR adds a
pressModeoption toMenuTrigger.Currently,
Menuopens onmousedown, which allows users to drag directly to select a menu item. This is a nice and intentional interaction design, however, there are cases where this behavior is not suitable.https://codesandbox.io/p/sandbox/z2jwsl
For example, when the element wrapping the trigger is draggable, it can be necessary to distinguish between a drag gesture and a menu interaction. In such cases, opening the menu on
clickrather thanmousedownprovides more appropriate behavior.There is a related discussion in Radix:
radix-ui/primitives#2867
At the moment, this behavior can be implemented using
onOpenChange/preventBaseUIHandler, but I thought it would be beneficial to support this use case directly in Base UI via an explicit option.Please note that this PR will conflict with #3631. I will address it as needed.