question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bindHover on menu

See original GitHub issue

hey there I’m trying to use bindHover with bindMenu 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

                        {
                            popupState => (
                                <React.Fragment>
                                    <MenuItem
                                        className={classes.menuItem}
                                        {...bindHover(popupState)}>
                                        {item.title}
                                    </MenuItem>
                                    <Menu
                                        anchorOrigin={{
                                            vertical: "bottom",
                                            horizontal: "right"
                                        }}
                                        className={classes.popover}
                                        getContentAnchorEl={null}
                                        TransitionComponent={Fade}
                                        {...bindMenu(popupState)}
                                    >
                                        elevation={1}
                                        >
                                        {
                                            item.subMenu.map((sub, j) =>
                                                <NavLink to={sub.path} key={j}>
                                                    <MenuItem
                                                        className={classes.subMenu}
                                                    >
                                                        {sub.title}
                                                    </MenuItem>
                                                </NavLink>
                                            )}
                                    </Menu>
                                </React.Fragment>
                            )
                        }
                    </PopupState>```

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:20 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
jedwards1211commented, Feb 16, 2019

@schemenauero btw, in this branch the hooks and render props APIs now share code under the hood and the hooks API supports bindHover 💪

1reaction
jedwards1211commented, Feb 15, 2019

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:

<div> (modal root)
  <div /> (backdrop)
  <div> (Paper)
    (popover content)
  </div>
</div>

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 Popover will accomplish what we need with hover interaction:

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 Popover wrapped with these styles for convenience (as well as a Menu).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the material-ui-popup-state.bindMenu function in ...
To help you get started, we've selected a few material-ui-popup-state.bindMenu examples, based on popular ways it is used in public projects.
Read more >
material-ui-popup-state change button color - Stack Overflow
I am using material-ui-popup-state to create a material ui drop down menu In my Navbar.js i ... bindHover(popupState)} selected={popupState.
Read more >
getcontentanchorel | The AI Search Engine You Control
hey there I'm trying to use bindHover with bindMenu but when mouse moves on sub menu list is closed… am I doing something...
Read more >
How to overwrite the properties of richwidget dropdown menu
I tried overwriting the javascript of dropdown menu richwidget by ... that's not a menu, closes all menus $( document.body ).bind( "hover", ...
Read more >
.hover() | jQuery API Documentation
A function to execute when the mouse pointer leaves the element. The .hover() method binds handlers for both mouseenter and mouseleave events. You...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found