-
Notifications
You must be signed in to change notification settings - Fork 28
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
bindHover on menu #3
Comments
Sorry for the delay, GitHub hadn't added me as a watcher of this package :( You're not doing anything wrong, but I'll try to solve this by checking in |
Okay, I released changes that should fix this in version 1.1.0. Can you install version 1.1.0 and let me know if it fixes your issue? Note: the fix only works if you pass a Also, if there is any space between the menu item and the submenu, it could close the submenu if the mouse is not moved quickly enough for the cursor to jump straight from the menu item to the submenu. One potential solution to this would be (if possible) put the menu item and submenu inside of a |
@jedwards1211 |
Okay either I need to refine my tests or try this out myself in a browser, the logic I added was supposed to close when the menu item or the submenu gets a |
@jedwards1211 let me know when new version released... |
Okay, the problem is that the menu I get by id is actually the container element that fills up the whole window, rather than the actual menu element. I'll figure out how to solve this... |
@Linton-Samuel-Dawson unfortunately it's pretty much impossible to detect if the mouse is over the trigger element in any clean way, because of the way Popover and Menu use Modal, which spams a big window-filling element to the document root, blocking pointer events. If I try to disable pointer events to that element so I can tell if the trigger element is being hovered, it prevents the menu from receiving any pointer events. I'm really angry at the Material UI team about this and I've complained loudly in their issue tracker about it. |
@Linton-Samuel-Dawson I'm sorry you've had trouble with this and that I haven't been able to figure out a way to make it work for you yet. I'm sure it's been frustrating for you too |
@jedwards1211 thank you for effort ... |
I got this working by using a popper (which doesn't have a backdrop) and putting the popper inside the button component. It looks like this (using hooks):
Also had to add an onMouseLeave to the button. Doesn't look like onMouseLeave is working with bindHover (which isn't in the hooks file). |
@schemenauero wow, you figured that out fast, considering I released the hooks API last night! It's funny too that you worked around the fact that I didn't add |
@schemenauero |
@jedwards1211 Yea, the mouseleave fires when it leaves the button/popper combo, so it works like @Linton-Samuel-Dawson desires I think. I had a problem where, when the Button had an onClick, it was overriding any components with onClick's in the popper (because the popper was the parent), but I fixed that by using a Link instead of a Button. A bit "hacky" to get it all to work, but it makes sense. A prop allowing us to disable the backdrop of Menu's would be nice, but I can't speak towards Material UI's priorities. I think it would be nice to either add bindHover to the hooks API so it works the same as the normal API or to reflect its absence in the documentation. The hooks API is great by the way, thank you! Allowed me to write cleaner code in fewer lines. |
You're welcome! To be perfectly clear, there is not just a backdrop, but also a modal root element enclosing the backdrop and the popover. It renders like this:
Popover hides the backdrop element, but there is currently no getting rid of the modal root element and mounting the Paper element by itself. So one has to make the modal root invisible to the mouse while keeping the paper visible to the mouse. I figured out that the following styles on the const styles = {
popover: {
pointerEvents: 'none',
},
paper: {
pointerEvents: 'auto',
},
}
...
<Popover
{...bindPopover(popupState)}
className={classes.popover}
classes={{
paper: classes.paper,
}} I don't want you guys to have to write these styles everywhere you use hover interaction though. I guess the best solution is to have this library export a |
@Linton-Samuel-Dawson @schemenauero okay guys, I've almost solved this, haven't published yet but I have a demo up! I'm working on this in the cascading-hover branch. |
@schemenauero btw, in this branch the hooks and render props APIs now share code under the hood and the hooks API supports |
Hy, can you push your code to the master branch please if you ended it ? |
Yeah I'll work on it, a few more things need to ne cleaned up |
ok thanks |
Okay this is released in 1.3.0! |
hey there
I'm trying to use
bindHover
withbindMenu
but when mouse moves on sub menu list is closed...am I doing something wrong ?
if not I think it's good feature to add
The text was updated successfully, but these errors were encountered: