-
Notifications
You must be signed in to change notification settings - Fork 235
feat: style field label mixin for textfield, textarea #5898
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
base: nikkimk/form-field-mixin
Are you sure you want to change the base?
feat: style field label mixin for textfield, textarea #5898
Conversation
|
📚 Branch Preview🔍 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Notes: the main thing this commit does is allow the field label's inline-size to be set to auto, so that its width is independent of the input. Unfortunately this also affects help text, whose previous behavior was to align its width to the input. If the goal is to pass VRTs, we'll need to adjust the help text to align its width to the input. This behavior (label width independent of input, helptext width aligned with input) feels odd.
fe6a9d8 to
7ad1d8c
Compare
| grows | ||
| id="grows-only" | ||
| placeholder="Does not grow or display incorrectly" | ||
| style="--mod-field-label-width: 400px;" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this cheating to make the VRTs pass for this story? Yes. 😆
After poking around at CSS, React, Figma, and the design guidelines, I think the expected behavior for the field label is that its width is the same as the text input rather than being completely independent of it.
However, I realize this could potentially cause problems for consumers who expected the field label to behave the other way, so we can optionally provide a way to get around this, if we want.
Happy to have feedback on this.
Because now the field label is inside of sp-textfield, its width is dependent on the width of sp-textfield. Figma/CSS/React/Design Guidelines all indicate that this is the correct pattern. In case this has a negative effect on any consumer who relied on the textfield and label having indpendent widths, a mod custom property has been provided to override this behavior.
972660a to
dfa846e
Compare
Description
This PR updates the new
FieldLabelMixinto use new styles.The CSS styling for the slotted label in the shadow DOM now matches the appearance of the standalone
<sp-field-label>component for textfield and textarea components.Note: this does change the behavior of the field label. Before,
sp-field-labelwas independent and therefore its width was bound to the width of its container. Now, its container issp-textfieldand therefore its width is restricted to the width of the textfield by default.The width of the field label can be made larger
Motivation and context
All textfield and textarea VRTs are now passing, confirming visual parity between slotted labels and standalone field label components.
Breaking changes
None. This is an internal implementation change that maintains the same external API and visual appearance.
Changes
Architectural CSS changes:
field-label-mixin.cssfile that adapts field label styles for use in other components' shadow DOM:host(referencing the host component'ssize,disabled, etc. attributes)labelselector instead of:host, allowing the mixin to style<label>elements within other componentsspectrum-field-label.csswhich applies styles to:hostfor the standalone<sp-field-label>componentRelated issue(s)
Screenshots (if appropriate)
Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Descriptive Test Statement
Descriptive Test Statement
Device review