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.

long text MenuItems should ellipse

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

This might be related: https://github.com/mui-org/material-ui/pull/3250 but i’m not sure

Expected Behavior

Menu item texts should ellipse

Current Behavior

They somehow don’t, not sure why as text-overflow: ellipse is present

Steps to Reproduce (for bugs)

  1. https://codesandbox.io/s/p5kj9zw2xq
  2. resize the screen till it is to small to display the menu items
  3. realize it doesn’t ellipse

Context

We have some menu item text which are to long on mobile.

Your Environment

Tech Version
Material-UI latest
React latest
browser chrome latest
etc

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

12reactions
sakulstracommented, May 15, 2018

For anyone stepping into the problem it seems like wrapping the inner content into a div seems to solve the problem for now:

<FormControl style={{ maxWidth: "150px" }}>
        <Select value="red">
          {options.map(option => (
            <MenuItem key={option._id} value={option._id}>
              <div style={{ overflow: "hidden", textOverflow: "ellipsis" }}>
                {option.name}
              </div>
            </MenuItem>
          ))}
        </Select>
      </FormControl>

@oliviertassinari thanks for pointing out the problem 👍 - wouldn’t have found the issue without you! Should this perhaps be the default behavior? or at least somehow be noted in the docs?

3reactions
oliviertassinaricommented, Sep 11, 2018

@nathanmarks Let’s document 2. then 😃. I’m adding the support for inherit so we don’t have to know the variant:

            <MenuItem>
              <Typography variant="inherit" noWrap>
                Label
              </Typography>
            </MenuItem>

Is there any way we could use ListItemText for this instead?

What do we win? Typography is the low-level text primitive block. Even better, I love how people can build their own Box component in https://github.com/jxnblk/styled-system#usage.

Read more comments on GitHub >

github_iconTop Results From Across the Web

long text MenuItems should ellipse · Issue #11380 - GitHub
We set display block in the menu list item. But I fear it will break the menu composition capabilities with the list item...
Read more >
When should I use a ellipsis in a Menu Item - Stack Overflow
You should add ellipses to the end of text only if you're truncating the text (this applies anywhere) ...
Read more >
When should an ellipsis be used in menu items? [duplicate]
Use ellipses on a menu item when a user who clicks it must provide further information, filtering or 'refining' the action somehow.
Read more >
text-overflow - CSS: Cascading Style Sheets - MDN Web Docs
The text-overflow CSS property sets how hidden overflow content is signaled to users. It can be clipped, display an ellipsis ('…
Read more >
Menus: UI Text Guidelines - Microsoft Learn
The ellipsis is a visual cue that the user must supply additional information to complete the command. For more information, see the Command ......
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