fix!: convert Input and TextField BEM classes to flat class names - #5127
fix!: convert Input and TextField BEM classes to flat class names#5127millus wants to merge 9 commits into
Conversation
Renames BEM element classes on the adornment sub-elements to flat names:
- eds-adornment__adornment → item
- eds-adornment__text → text
Also nests .item and .text inside .eds-adornment {} using CSS nesting,
and restructures the adornment button rules to be co-located.
BREAKING CHANGE: consumers targeting these class names directly in their
own CSS must update to the new flat names.
Renames BEM element classes to flat names scoped by CSS nesting: - eds-text-field__header → header - eds-text-field__info → info Adds eds-text-field as the root class on the Field wrapper so the inner elements can be properly scoped with CSS nesting — consistent with how Radio and Checkbox add their own class to the Field wrapper. BREAKING CHANGE: consumers targeting these class names directly in their own CSS must update to the new flat names.
Documents the decision to use flat class names scoped by CSS nesting for EDS 2.0 /next components, superseding the BEM-inspired naming mentioned in ADR 0002. Closes #5104
Inner elements of eds-input-container should not carry the eds- prefix — only the root class does. Renames: - eds-input → input - eds-adornment → adornment - eds-error-icon → error-icon Also fully nests all inner element rules inside .eds-input-container using CSS nesting, removing the separate top-level blocks. BREAKING CHANGE: consumers targeting these class names directly in their own CSS must update to the new flat names.
Aligns Input with the convention that only the outermost element carries the eds- prefix: - eds-input-container → eds-input (root wrapper, renamed to match component) - input → control (inner <input>/<textarea> element) Also updates all cross-component references in textarea.css, autocomplete.css, and elements.css (the :not() exclusion for base input styles). BREAKING CHANGE: consumers targeting eds-input-container or the input class on the inner element must update to eds-input and control.
|
@claude review |
|
Claude finished @pomfrida's task in 3m 4s —— View job Review:
|
pomfrida
left a comment
There was a problem hiding this comment.
Very nice 👏 Approved with minor comments
| [type='checkbox'], [type='radio'], | ||
| [type='range'], [type='color'], [type='file'], [type='image'], | ||
| [type='submit'], [type='reset'], [type='button'], .eds-input | ||
| [type='submit'], [type='reset'], [type='button'], .control |
There was a problem hiding this comment.
.control is a really common class name, so this can now accidentally exclude a consumer's own <input class="control"> from the foundation styles. What we actually want to exclude is "an input inside our Input", so maybe:
[type='submit'], [type='reset'], [type='button'], .eds-input input| & .text, | ||
| & .item, |
There was a problem hiding this comment.
Adornments can contain any markup, so & .text etc. will also hit consumer elements that happen to use these class names. Everything here is a direct child, so using > (& > .adornment > .text etc.) avoids that for free. Same for & .header in text-field.css.
I realise Banner and Field/Switch/Radio/Checkbox use the same descendant pattern and I only spotted this now, so not blocking this PR on it, I can open a follow-up issue to sweep all the components and get it into the ADR. Feel free to use > here already if you agree though.
| const hasEndAdornment = endText || endAdornment | ||
|
|
||
| const containerClasses = ['eds-input-container', containerClassName] | ||
| const containerClasses = ['eds-input', containerClassName] |
There was a problem hiding this comment.
Since eds-input used to be the inner input and is now the container, existing CSS against it won't break visibly — it just starts styling the wrong element. Worth mentioning that in the BREAKING CHANGE note, e.g. ".eds-input is now the container; the inner input is .control." A specific footer also avoids the manual dedup we had to do in the release PR after #5114/#5115, where the identical footer texts ended up as duplicate changelog entries.
Summary
Converts Input and TextField from BEM-style class names to the flat class name convention. Part of #5104. This is the last of three component PRs — see also #5114 (Banner) and #5115 (Field + Switch + Radio + Checkbox). ADR 0006 documenting the convention is in #5134.
Changes
Input — full class name cleanup:
eds-input-containereds-input(root, renamed to match component)eds-inputcontrol(inner<input>/<textarea>element)eds-adornmentadornmenteds-error-iconerror-iconeds-adornment__adornmentitemeds-adornment__texttextAll inner element rules are now fully nested inside
.eds-inputusing CSS nesting. Cross-component references intextarea.css,autocomplete.css, andelements.cssupdated accordingly.TextField:
eds-text-field__header→headereds-text-field__info→infoAdds
eds-text-fieldas the root class on theFieldwrapper so inner elements can be properly scoped — consistent with howRadioandCheckboxadd their own class to theFieldwrapper.BREAKING CHANGE: Consumers targeting these class names directly in their own CSS must update to the new flat names.
Closes #5104
Test plan
npx jest --testPathPatterns="next/Input|next/TextField|next/TextArea|next/Autocomplete" --no-coverage— 133 tests pass