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.

[Menu] Remove MenuItem dependency on ListItem

See original GitHub issue

A 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>

image

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:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Jun 27, 2020

@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.

0reactions
oliviertassinaricommented, Jun 6, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

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