Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EuiBadge truncation #2190

Merged
merged 9 commits into from
Aug 1, 2019
Merged

Fix EuiBadge truncation #2190

merged 9 commits into from
Aug 1, 2019

Conversation

cchaos
Copy link
Contributor

@cchaos cchaos commented Aug 1, 2019

Fixes #2189

Luckily it was mostly a matter of a missing class and missing truncation mixin. I also needed to add a max-width: 100% otherwise it wouldn't stop at the container's width.

Before -- no max-width

It wouldn't even truncate at all
Screen Shot 2019-08-01 at 12 10 05 PM

Before -- with max-width

When it did truncate, it didn't do so correctly
Screen Shot 2019-08-01 at 12 10 25 PM

After

Now it truncates no matter the contents. I also added the innerText to the title attribute of the surrounding content so that consumers don't have to worry about adding this or tooltips to show the full text.

Screen Shot 2019-08-01 at 12 09 06 PM

Checklist

  • [ ] Checked in dark mode
  • Checked in mobile
  • Checked in IE11 and Firefox
  • [ ] Props have proper autodocs
  • [ ] Added documentation examples
  • Added or updated jest tests
  • [ ] Checked for breaking changes and labeled appropriately
  • [ ] Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to add a doc example so people don't get surprised by this. I think that's especially true if we do a more strict max width.

src/components/badge/_badge.scss Outdated Show resolved Hide resolved
- Added docs example for truncations
- Duplicated the `aria-label` as the `title` on the clickable icon
- Keeping the `ref` and `title` attributes to the same element as `…rest` so they can be overridden
- Fix max width of badges with onClick and iconOnClick
- Fix text alignment
- Change cursor to default unless clickable
@cchaos
Copy link
Contributor Author

cchaos commented Aug 1, 2019

Ok I also added a docs section for truncation which also explains the title stuff.

Screen Shot 2019-08-01 at 16 34 38 PM

And good thing I did because I found a few more fixes detailed in this commit message.

@cchaos cchaos requested a review from snide August 1, 2019 20:36
Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double approved!!!

image

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge conflicts?

@cchaos cchaos requested a review from thompsongl August 1, 2019 21:16
@cchaos cchaos merged commit 263e7c9 into elastic:master Aug 1, 2019
@cchaos cchaos deleted the badge-truncation branch August 1, 2019 21:49
@cchaos cchaos mentioned this pull request Aug 2, 2019
4 tasks
thompsongl pushed a commit to thompsongl/eui that referenced this pull request Sep 10, 2019
* Fix badge truncation when a `<button>`
* Added innerText to title attribute
* Fix truncation if button is the child
* Max width accounts for padding, etc.
* Some more fixes
- Added docs example for truncations
- Duplicated the `aria-label` as the `title` on the clickable icon
- Keeping the `ref` and `title` attributes to the same element as `…rest` so they can be overridden
- Fix max width of badges with onClick and iconOnClick
- Fix text alignment
- Change cursor to default unless clickable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Badges don't truncate (well)
3 participants