Skip to content

Replace fragile bare-span truncation selectors in InputWrapper and Select with class-based targeting #1303

Open

Description

@ignovak

Background

Follow-up from #1302 (fix: render the Icon wrapper as a span for valid inline nesting).

Two components truncate text with a bare-element selector that was ported verbatim from the styled-components era:

  • InputWrapper — .wrapper span:first-of-type (src/components/InputWrapper/InputWrapper.module.css)
  • Select — .select-trigger span:first-of-type (src/components/Select/common/SelectComponents.module.css)

Both apply max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;.

Because #1302 changed the Icon wrapper from <div> to <span>, those selectors now also match icon wrappers rendered inside these components (e.g. the TextField loading/clear icons, the Select sort icon). Today this is visually neutral — Chromatic shows zero diffs, since the styles are inert on a span that wraps a fixed-size SVG with no text — so it is not a current regression. It is a latent fragility: a future icon with state padding/background or a focus ring in one of these slots could be clipped by overflow: hidden.

Why a separate PR

The selectors legitimately truncate text spans (e.g. EllipsisContent, consumer-provided start/end content), and icons are now spans too, so this cannot be a one-line fix:

  • Scoping Select to .select-value excludes the sort icon but not a start-positioned item icon nested inside the value.
  • InputWrapper's .wrapper span:first-of-type has no single CUI text element that clearly owns it; it appears to primarily truncate consumer-provided start/end content (or is partly vestigial).

Doing it right means re-pointing truncation at the intended text element via a class and re-validating truncation across TextField, PasswordField, SearchField, DatePicker, and single/multi Select, with its own visual baseline. That is out of scope for the focused icon fix (one concern per PR).

Proposed work

  • Give the truncated text element a dedicated class in each component and target that, instead of span:first-of-type.
  • Confirm icon wrappers no longer match the truncation rules.
  • Re-run the visual specs for all affected components; any snapshot change must be intended and explained.

Acceptance

  • No bare-element (span / div) selectors remain for truncation in InputWrapper or Select.
  • Truncation behavior is unchanged (visual specs green, zero unexplained diffs).

Activity

  1. ignovak commented on Nov 12, 2026

    @ignovak
    ContributorAuthor

    Note: these selectors are live — repoint, do not remove

    Investigated whether .wrapper span:first-of-type is vestigial. It is not safe to delete:

    • InputWrapper .wrapper span:first-of-type truncates the date-range value: DateRangePickerInput / DateTimeRangePickerInput (src/components/DatePicker/Common.tsx) render the formatted range as a <span> (formattedValue), and this rule ellipsizes it. Covered by tests/display/daterangepicker.spec.ts. It also affects consumer-supplied span startContent/endContent (e.g. NumberField $).
    • Select .select-trigger span:first-of-type truncates the EllipsisContent value-text span in the trigger.

    History: the InputWrapper rule was introduced in #55 (Aug 2023) and carried verbatim through the SCSS and CSS-Modules migrations. The Icon wrapper was a div from that same era until #1302 changed it to a span, which is why these selectors only started matching icon wrappers now.

    So the fix is to point truncation at the real text element via a class (the DateRange formattedValue span; the Select value text), not to remove the rule. Keep daterangepicker.spec.ts, the Select specs, and NumberField start/end-content stories green as the guardrail.

  2. oranjan commented on Nov 28, 2026

    @oranjan

    Hi @ignovak, I'd like to take this one. My plan:

    • InputWrapper: add a .wrapper__value class (with an InputValue slot next to InputStartContent/InputEndContent) and use it for the date-range value in DatePicker/Common.tsx, then drop .wrapper span:first-of-type.
    • Select: it looks like the trigger's text already truncates through .select-value-container and EllipsisContent (which renders a div), so .select-trigger span:first-of-type seems to only hit the sort and option icons. I'd remove it and rely on the visual specs to confirm nothing changes.
    • One question: consumer-provided span startContent/endContent would stop truncating. Is that OK?

    Does that match what you had in mind?

  3. oranjan commented on Nov 28, 2026

    @oranjan

    withdrawing since #1331 already covers this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions