[MenuItem] SubItem Collapsing when setState is called in container
Problem description
I'm constrained to build a nested popover menu in my render method. And every time I setState ( and render a new menu) The popover behaves differently based on which nested MenuItem I have open.
Each
Link to minimally-working code that reproduces the issue
I've linked a code example. Please click the button labeled "Click Me", then open up each menuItem's subMenus, and try and click (directly) on the input/checkbox. The first submenu will remain open and the rest of them will close onTouchTap event. I've tried including several other event handlers to prevent default on and none work.
WebpackBin: http://www.webpackbin.com/4kX-28iDz
Versions
- Material-UI: "0.16.7",
- React: "15.4.2"
- Browser: 55.0.2883.95 (64-bit)
I spent a decent amount of time trying to figure out what is causing this, but could not find an answer. I believe it's specifically related to the interaction between using a Checkbox component for the primaryText attribute.
Ultimately, the currently implemented API is to close on click (see this line in MenuItem). I checked this is consistent across menu items and it is (see this WebpackBin)
Do you know how I could keep the menu open through click events? I need nested dropdown menu to stay open so I can click multiple checkboxes. Or do you have any suggestion how to create a similar feature with other components?
@KevinMongiello event.stopPropagation?
@mbrookes Doesn't work. I included that in the onTouchTap handler for the checkboxes in the WebpackBin with no avail.
@KevinMongiello This may be related to #5104
@mattste Yeah It very well might be, I remember reading that thread but it doesn't look like there was any real resolution since under certain circumstances the checkboxes appear to respond to preventDefault / stopPropagation
We have been porting the component on the v1-beta branch. We reimplemented it from the ground-up. While we haven't tested it, I think that the issue is most likely fixed on that branch. Hence, I'm closing it. Still, we will accept PR fixes until v1-beta takes over the master branch.