[Menu] Remove MenuItem dependency on ListItem
See original GitHub issueA 4px margin was added to the top and bottom of ListItemText
in https://github.com/mui-org/material-ui/pull/15339, causing an inconsistency between items that use it and items that just have a string child.
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
The MenuItems
in this JSX render with different heights when the viewport width >= 600:
<MenuList>
<MenuItem style={{ backgroundColor: "green" }}>
without ListItemText
</MenuItem>
<MenuItem style={{ backgroundColor: "red" }}>
<ListItemText>with ListItemText</ListItemText>
</MenuItem>
</MenuList>
When the viewport is narrower than 600px, a media query deactivates and their minHeight
becomes 48px (ironically causing them to get taller on narrower screens…)
Expected Behavior 🤔
The menu items are the same height, like they used to be
Steps to Reproduce 🕹
https://codesandbox.io/s/blazing-resonance-oqiso?file=/src/Demo.js
Context 🔦
Discovered this working on material-ui-popup-state
demos.
Your Environment 🌎
Refer to code sandbox for versions
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
[Menu] Remove MenuItem dependency on ListItem #21587
Deprecate MenuItem in v5, change all the docs to use new ListItemButton (based on the outcome of improvement), remove MenuItem in v6. This...
Read more >context menu for removing items in listview - wpf
ContextMenus are disconnected, you cannot use ElementName bindings. One workaround would be using Binding.Source and x:Reference which requires ...
Read more >Menus - Android Developers
With this change, Android apps should migrate away from a dependence on the traditional 6-item menu panel and instead provide an app bar...
Read more >Add and Remove Menu Items with ContextMenu Component
Use the Remove or RemoveAt method of the MenuItems collection of the ContextMenu component to remove a particular menu item.
Read more >Menus - Lightning Design System
To create a menu with a submenu, add the slds-has-submenu class to the list item, <li> , that will open the submenu. Accessibility...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jedwards1211 Ok, thanks for the extra information. I think that we will need to revamp the List and Menu implementation in v5. One element that has came up is that it’s not a good idea to share the same style for both. So I think that we need to stop using this MenuItem > ListItem inheritance.
@siriwatknp I think that we will always need different components for rendering a list item, a menu item, and maybe a listbox item (select). Because it works in Material Design with the same component doesn’t mean it will work in most design systems. I would definitely encourage 2 without any dependency on the list.