Skip to content

Commit 7ad1d8c

Browse files
fix(textfield,numberfield): inline sizing
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.
1 parent c1be5d2 commit 7ad1d8c

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

1st-gen/packages/number-field/src/number-field.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,14 @@
3939
/* TODO: added stepper-button-width multiplied by 2 just to give extra space to the input field.
4040
That "2" is a magic number and should be removed when we are able (possibly after S2 migration). */
4141
--spectrum-stepper-width: calc(var(--mod-stepper-height, var(--spectrum-stepper-height)) * var(--mod-stepper-min-width-multiplier, var(--spectrum-text-field-minimum-width-multiplier)) + var(--mod-stepper-button-width, var(--spectrum-stepper-button-width)) * 2 + var(--mod-stepper-border-width, var(--spectrum-stepper-border-width)) * 2);
42-
43-
/* resets the inline-size of sp-number-field to the newly defined stepper-width */
44-
inline-size: var(--mod-stepper-width, var(--spectrum-stepper-width));
4542
}
4643

4744
:host([hide-stepper]) {
4845
--spectrum-stepper-width: calc(var(--mod-stepper-height, var(--spectrum-stepper-height)) * var(--mod-stepper-min-width-multiplier, var(--spectrum-text-field-minimum-width-multiplier)) + var(--mod-stepper-button-width, var(--spectrum-stepper-button-width)) + var(--mod-stepper-border-width, var(--spectrum-stepper-border-width)) * 2);
4946
}
5047

51-
/* keeps the textfield 100% of the width of the sp-number-field so there isn't a gap between the containers */
5248
#textfield {
53-
inline-size: 100%;
49+
inline-size: var(--mod-stepper-width, var(--spectrum-stepper-width));
5450
}
5551

5652
.input {

1st-gen/packages/number-field/src/spectrum-number-field.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
--mod-infield-button-border-color: var(--highcontrast-stepper-border-color-keyboard-focus, var(--mod-stepper-buttons-border-color-keyboard-focus, var(--spectrum-stepper-buttons-border-color-keyboard-focus)));
153153
--mod-textfield-focus-indicator-width: 0;
154154
--mod-textfield-border-color: var(--highcontrast-stepper-border-color-keyboard-focus, var(--mod-stepper-border-color-keyboard-focus, var(--spectrum-stepper-border-color-keyboard-focus)));
155+
155156
outline: var(--spectrum-stepper-focus-indicator-width) solid;
156157
outline-color: var(--spectrum-stepper-focus-indicator-color);
157158
outline-offset: var(--spectrum-stepper-focus-indicator-gap);
@@ -248,8 +249,6 @@
248249
}
249250

250251
#textfield {
251-
--spectrum-stepper-width: var(--mod-stepper-width, calc(var(--spectrum-stepper-height) * var(--mod-stepper-min-width-multiplier, var(--spectrum-text-field-minimum-width-multiplier)) + var(--spectrum-stepper-button-width) + var(--mod-stepper-border-width, var(--spectrum-stepper-border-width)) * 2));
252-
inline-size: var(--spectrum-stepper-width);
253252
block-size: var(--spectrum-stepper-height);
254253
border-radius: var(--spectrum-stepper-border-radius);
255254
flex-flow: row;

1st-gen/packages/textfield/src/textfield.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
:host {
1717
display: inline-flex;
1818
flex-direction: column;
19-
inline-size: var(--mod-textfield-width, var(--spectrum-textfield-width));
19+
inline-size: auto;
2020
}
2121

2222
:host([multiline]) {
@@ -32,7 +32,7 @@
3232
}
3333

3434
#textfield {
35-
inline-size: 100%;
35+
inline-size: var(--mod-textfield-width, var(--spectrum-textfield-width));
3636
}
3737

3838
#textfield,

0 commit comments

Comments
 (0)