mui / mui/material-ui

[Menu] Does not add margin if the first item is a `Divider`

Open
#32,986 1 comment 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

has workaround scope: menu waiting for 👍
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Duplicates
  • I have searched the existing issues
Latest version
  • I have tested the latest version
Current behavior 😯

see https://codesandbox.io/s/iconmenu-demo-material-ui-forked-i2xk9i for a code example.

Today, by an error of a CSS selector (in my opinion), a Divider will not get correct margin-bottom (and thus be very close to the first MenuItem).

This bug has two causes based on the selector (https://github.com/mui/material-ui/blob/master/packages/mui-material/src/MenuItem/MenuItem.js#L115) used:

  1. the style is appended to MenuItem not Menu
  2. the style uses the + CSS selector which means it will only select dividers placed immediately after menu items. in the case of a divider being first, though, this will never match.
Expected behavior 🤔
BEFORE AFTER
Screenshot_20220601_153611 Screenshot_20220601_153542

There should be a margin bottom for the first item if it is a Divider.

Steps to reproduce 🕹

Steps:

  1. Create a Menu and add a Divider before any MenuItem.
Context 🔦

Consider the case of a UI that has divided menu items like this from Insomnia:

In this kind of UI, it's very common to have a divider beginning a menu item list.

Your environment 🌎

The docs. See link above.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.