Skip to content
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

[IconMenu] Calling .open from a click handler causes menu to close #1254

Closed
JAStanton opened this issue Jul 23, 2015 · 1 comment
Closed
Labels
component: menu This is the name of the generic UI component, not the React module! package: icons Specific to @mui/icons

Comments

@JAStanton
Copy link
Contributor

Setup basically looks like, you click an element with a onTouchTap handler that should open iconMenu. however the iconMenu's detect click away logic fires and immediately closes the menu after it starts to open :( The only way I can get this to work is to put my click event handler logic in a setTimeout.

_openMenu = () => {
  // weird bug
  setTimeout(() => {
  this.refs.menu.open()
  }, 1);
}

render() {
  return (
    <span>
      <div onTouchTap={this._openMenu}> </div>
      <IconMenu ref='menu'> ... </IconMenu>
    </span>
  );
}
JAStanton added a commit to JAStanton/material-ui that referenced this issue Jul 30, 2015
Adds an isOpen method to an iconMenu. 

The way I'm using this is that I am programmatically opening / closing the menu from a different user action.

```jsx
  _toggleMenuState = () => {
    let isOpen = this.refs.menu.isOpen();
    // weird bug mui#1254
    setTimeout(() => {
      if (isOpen) {
        this.refs.menu.close()
      } else {
        this.refs.menu.open()
      }
    }, 1);
  }
```
There is actually a related bug here: mui#1254 to make this work.
@shaurya947
Copy link
Contributor

Assuming this is okay to close since #1288 was merged.

@zannager zannager added package: icons Specific to @mui/icons component: menu This is the name of the generic UI component, not the React module! labels Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: menu This is the name of the generic UI component, not the React module! package: icons Specific to @mui/icons
Projects
None yet
Development

No branches or pull requests

3 participants