[Chip] Support overflow ellipsis by default

See original GitHub issue
  • 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 😯

My chips might contain very long strings (e.g. “Antigonish_NOVA_SCOTIA_CANADA_A1B2C3_7b2b3b4b1b2b3ffba3b4b5cd_ZZZ”), so I would like to limit the width of the chip, and show the full text in a Tooltip.

However after setting a maxWidth, and customizing the overflow CSS, I unexpectedly see:

  • a truncated section from the middle of the string
  • no ellipsis
  • the Chip’s delete button has disappeared
  chip: {
    maxWidth: 100,
    whiteSpace: "nowrap",
    overflow: "hidden",
    textOverflow: "ellipsis"
  }

chipcss

If I instead use “withStyles” and create my own StyledChip, and override the “label” portion of the styling, it is almost there, but I still don’t see the ellipsis, and now I’ve lost the left-padding on the delete button:

const StyledChip = withStyles(theme => ({
  root: {
    maxWidth: 100
  },
  label: {
    whiteSpace: "nowrap",
    overflow: "hidden",
    textOverflow: "ellipsis"
  }
}))(Chip);

almost

Expected Behavior đŸ€”

By setting a maxWidth, overflow:hidden and textOverflow:ellipsis, I expected to see a narrower Chip, displaying the first x characters of the string, then an ellipsis
 and the delete button should remain visible.

Steps to Reproduce đŸ•č

I modified the Chips example from Material-UI docs to demonstrate the issue: https://codesandbox.io/s/material-demo-zt72h

Context 🔩

My chips might contain very long strings, so I would like to limit the width of the chip, and show the full text in a Tooltip.

Your Environment 🌎

Tech Version
Material-UI v4.7.0
React v16.12.0
Browser Chrome
TypeScript
etc.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
suliskhcommented, Dec 3, 2019

Is there any ongoing work or PR? If no, I would be happy to contribute to this issue

1reaction
mbrookescommented, Nov 30, 2019

Does it have a potential negative impact?

I can’t think of any.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Chip] Support overflow ellipsis by default #18587 - GitHub
Display flex containers can't overflow ellipse, I believe it's a limitation of the platform. In our case, it doesn't seem that we need...
Read more >
CSS text-overflow: ellipsis not working on V-chip
I want to limit the width of a v-chip by using text-overflow: ellipsis but it seems that Vuetify v-chip doesn't recognize it.
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 >
Overflow content - Carbon Design System
Overflow content is text, such as a paragraph or a text string, that exceeds a desired space. It also applies to a series...
Read more >
Chip API - Material UI - MUI
Rule name Global class Description root.MuiChip‑root Styles applied to the root element. avatar.MuiChip‑avatar Styles applied to the avatar element. icon.MuiChip‑icon Styles applied to the icon element....
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