Skip to content

Commit f426a67

Browse files
authored
Form control heights (twbs#26820)
* Redo input height on .form-control - Use the already present -height variables on .form-control - Consolidate the select size and multiple overrides into the .form-control base class instead of sm/lg modifiers - Remove the Sass extends from input groups since it picks up too many selectors * Prevent height on textareas
1 parent 48c723b commit f426a67

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

scss/_forms.scss

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
.form-control {
88
display: block;
99
width: 100%;
10+
height: $input-height;
1011
padding: $input-padding-y $input-padding-x;
1112
font-size: $font-size-base;
1213
line-height: $input-line-height;
@@ -57,10 +58,6 @@
5758
}
5859

5960
select.form-control {
60-
&:not([size]):not([multiple]) {
61-
height: $input-height;
62-
}
63-
6461
&:focus::-ms-value {
6562
// Suppress the nested default white text on blue background highlight given to
6663
// the selected option text when the (still closed) <select> receives focus
@@ -139,35 +136,36 @@ select.form-control {
139136
// Build on `.form-control` with modifier classes to decrease or increase the
140137
// height and font-size of form controls.
141138
//
142-
// The `.form-group-* form-control` variations are sadly duplicated to avoid the
143-
// issue documented in https://github.com/twbs/bootstrap/issues/15074.
139+
// Repeated in `_input_group.scss` to avoid Sass extend issues.
144140

145141
.form-control-sm {
142+
height: $input-height-sm;
146143
padding: $input-padding-y-sm $input-padding-x-sm;
147144
font-size: $font-size-sm;
148145
line-height: $input-line-height-sm;
149146
@include border-radius($input-border-radius-sm);
150147
}
151148

152-
select.form-control-sm {
153-
&:not([size]):not([multiple]) {
154-
height: $input-height-sm;
155-
}
156-
}
157-
158149
.form-control-lg {
150+
height: $input-height-lg;
159151
padding: $input-padding-y-lg $input-padding-x-lg;
160152
font-size: $font-size-lg;
161153
line-height: $input-line-height-lg;
162154
@include border-radius($input-border-radius-lg);
163155
}
164156

165-
select.form-control-lg {
166-
&:not([size]):not([multiple]) {
167-
height: $input-height-lg;
157+
// stylelint-disable no-duplicate-selectors
158+
select.form-control {
159+
&[size],
160+
&[multiple] {
161+
height: auto;
168162
}
169163
}
170164

165+
textarea.form-control {
166+
height: auto;
167+
}
168+
// stylelint-enable no-duplicate-selectors
171169

172170
// Form groups
173171
//

scss/_input-group.scss

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,23 @@
122122
.input-group-lg > .input-group-append > .input-group-text,
123123
.input-group-lg > .input-group-prepend > .btn,
124124
.input-group-lg > .input-group-append > .btn {
125-
@extend .form-control-lg;
125+
height: $input-height-lg;
126+
padding: $input-padding-y-lg $input-padding-x-lg;
127+
font-size: $font-size-lg;
128+
line-height: $input-line-height-lg;
129+
@include border-radius($input-border-radius-lg);
126130
}
127131

128132
.input-group-sm > .form-control,
129133
.input-group-sm > .input-group-prepend > .input-group-text,
130134
.input-group-sm > .input-group-append > .input-group-text,
131135
.input-group-sm > .input-group-prepend > .btn,
132136
.input-group-sm > .input-group-append > .btn {
133-
@extend .form-control-sm;
137+
height: $input-height-sm;
138+
padding: $input-padding-y-sm $input-padding-x-sm;
139+
font-size: $font-size-sm;
140+
line-height: $input-line-height-sm;
141+
@include border-radius($input-border-radius-sm);
134142
}
135143

136144

0 commit comments

Comments
 (0)