[DropdownMenu] Open on trigger-hover
Feature request
Overview
Currently it seems that only clicking on the DropdownMenu.Trigger opens the Dropdownmenu.
I would like already open it when hovering over the trigger.
Who does this impact? Who is this for?
This is for myself and would help me implement a menubar where the dropdown is the 2nd level that pops up when I hover over the 1st level menu items.
Hi @rejas,
If I understand correctly, based on what you are mentioning it sounds like you are using the wrong component for the job and what you are after is components to build a menu bar (like on top of any app, or in MacOS top menu bar).
MenuBar is a component we are planning to work on soon, which is basically a different composition of Menu (similar to what we do with DropdownMenu and ContextMenu). When we release it, it will work exactly like MacOS menu bar, so initial menu would open on click, but then you could hover to another one to open the next.
Yes, you are right, it's a menubar, but since I saw that this is not (yet) implemented, I hoped I could use the DropdownMenu.
But isnt "open on hover" something the Dropdown Menu could offer regardless?
Yes, you are right, it's a menubar, but since I saw that this is not (yet) implemented, I hoped I could use the DropdownMenu.
Yeah, it's one of the ones that's next on our list.
But isnt "open on hover" something the Dropdown Menu could offer regardless?
Potentially, but there are a few things that would need to be considered for that to work correctly, so we'd have to rethink pointer handling a bit.
@rejas Our components have a controlled API to allow you to customise things: https://codesandbox.io/s/solitary-fog-ueqpb?file=/src/App.js
@benoitgrelard Interesting that I had to add pointerEvents: 'auto' to the trigger there. I wonder if we should be doing that internally?
@benoitgrelard Interesting that I had to add
pointerEvents: 'auto'to the trigger there. I wonder if we should be doing that internally?
It makes sense because of the dismissable layer. But that's what I mean though, the minute we'd want to allow hover as part of the API I think there's a lot more to it, similar constraints that we have on HoverCard and Tooltip that work with hover interactions, like implementing delays to prevent opening instantly, etc.
the minute we'd want to allow hover as part of the API
Ah sorry, I don't think we should provide a hover API. The controlled API can achieve that just fine 👍
My question was more because I didn't expect the trigger to have pointer-events: none since it is part of the menu. I understand that it is modal but the prop is on Root part so I thought both parts would be pointer-events: auto for some reason 😅
Thanks for the help, I solved it indeed with the controlled api part of your library. Will close this issue now since it isnt really a feature the lib needs as I see now. Thanks again for your work!
@jjenzz When there's a gap between the trigger and the content (using portal), it closes the dropdown when moving the mouse to the content. Is there a way to fix it?
@gabrielmlinassi are you using the sideOffset prop? everything is working correctly here https://codesandbox.io/p/sandbox/eloquent-hertz-9sd9hw?file=%2FApp.jsx%3A25%2C77