Skip to content

Add shared ellipsis truncation to Badge/Label components#26493

Merged
dennisoelkers merged 4 commits into
masterfrom
fix/badge-label-ellipsis-truncation
Jun 30, 2026
Merged

Add shared ellipsis truncation to Badge/Label components#26493
dennisoelkers merged 4 commits into
masterfrom
fix/badge-label-ellipsis-truncation

Conversation

@dennisoelkers

@dennisoelkers dennisoelkers commented Jun 26, 2026

Copy link
Copy Markdown
Member

Description

Adds the CSS plumbing so Badge and Label can truncate overflowing text with an ellipsis when they are width-constrained:

  • Badge no longer forces width: fit-content; it allows min-width: 0 / max-width: 100% so it can shrink as a flex/grid item, and its .mantine-Badge-label now uses overflow: hidden + text-overflow: ellipsis + white-space: nowrap.
  • Label adds the same single-line ellipsis context to a child <span> (e.g. one carrying a title tooltip), so wrapped content truncates instead of overflowing.

This is the shared building block the Enterprise change Use shared Label truncation for MITRE category chips builds on, letting it drop its local CategoryLabel styled wrapper.

Fixes https://github.com/Graylog2/graylog-plugin-enterprise/issues/14582

Motivation and Context

Long text inside badges/labels overflowed their container instead of truncating. Centralizing the truncation behavior in the base components avoids per-call-site styled wrappers.

How Has This Been Tested?

Verified in the web interface that long badge/label content now truncates with an ellipsis when constrained, and renders unchanged when it fits.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have requested a documentation update.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

/nocl Internal refactoring of shared Badge/Label styling with no user-facing behavior change.

After the Mantine migration the `Badge` (and the `Label` built on it) stopped
abbreviating long text: the label's `overflow: visible` cancelled Mantine's
ellipsis, and the root's `width: fit-content` floored the badge at its text
width so it never had a constrained width to truncate against.

Let the badge shrink (`min-width: 0` / `max-width: 100%`), make the label a
single-line ellipsis context, and give a span-wrapped label child (e.g. content
carrying a `title` tooltip) its own ellipsis context. Padding is preserved, so
the truncated text keeps a minimum left/right gap.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@systemboogie

Copy link
Copy Markdown

@dennisoelkers

The bug with the MITRE chips mentioned in https://github.com/Graylog2/graylog-plugin-enterprise/issues/14582 seems fixed, thank you! However, the tag chips do not get truncated and can therefore overlap with other column's content. See screen recording.

Untitled.mov

@dennisoelkers

Copy link
Copy Markdown
Member Author

@systemboogie: Should be fixed now. Can you retest?

@dennisoelkers dennisoelkers merged commit ea0d988 into master Jun 30, 2026
25 checks passed
@dennisoelkers dennisoelkers deleted the fix/badge-label-ellipsis-truncation branch June 30, 2026 08:46
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.

2 participants