Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit e2af2a3

Browse files
committed
fix(select): height changes when disabled
- use the same approach for `md-select`'s disabled border background-position as `md-input` - `md-select` inside of an `md-input-container` uses more `md-input` SCSS variables - this allows it to better match the layout and dimensions of other `md-input-container` elements - add new `$select-border-width-default` SCSS variable Fixes #11812
1 parent 9f49e10 commit e2af2a3

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

src/components/select/select.scss

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
$select-checkbox-border-radius: 2px !default;
22
$select-checkbox-border-width: 2px !default;
3+
$select-border-width-default: 1px !default;
34
$select-checkbox-width: rem(1.4) !default;
45
$select-option-height: 48px !default;
56
$select-option-padding: 16px !default;
@@ -115,12 +116,14 @@ md-select {
115116
}
116117

117118
&[disabled] .md-select-value {
118-
background-position: 0 bottom;
119+
// This background-position was taken from the styling of disabled md-inputs.
120+
// The negative border width offsets the dotted "border" so it's placed in the same place as the
121+
// solid one before it.
122+
background-position: bottom $select-border-width-default * -1 left 0;
119123
// This background-size is coordinated with a linear-gradient set in select-theme.scss
120124
// to create a dotted line under the input.
121125
background-size: 4px 1px;
122126
background-repeat: repeat-x;
123-
margin-bottom: -1px; // Shift downward so dotted line is positioned the same as other bottom borders
124127
}
125128

126129
&:focus {
@@ -141,7 +144,7 @@ md-select {
141144
}
142145
&:focus {
143146
.md-select-value {
144-
border-bottom-width: 2px;
147+
border-bottom-width: $select-border-width-default + 1px;
145148
border-bottom-style: solid;
146149
padding-bottom: 0;
147150
}
@@ -154,18 +157,34 @@ md-select {
154157
}
155158
}
156159

157-
// Fix value by 1px to align with standard text inputs (and spec)
158-
md-input-container.md-input-has-value .md-select-value {
159-
> span:not(.md-select-icon) {
160-
transform: translate3d(0, 1px, 0);
160+
md-input-container md-select {
161+
&:not([disabled]) {
162+
&:focus {
163+
.md-select-value {
164+
border-bottom-width: $input-border-width-focused;
165+
}
166+
}
167+
}
168+
&[disabled] {
169+
.md-select-value {
170+
// This background-position was taken from and matches the styling of disabled md-inputs.
171+
// The negative border width offsets the dotted "border" so it's placed in the same place as
172+
// the solid one before it.
173+
background-position: bottom $input-border-width-default * -1 left 0;
174+
}
175+
}
176+
.md-select-value {
177+
min-height: ($input-line-height + $input-padding-top * 2) - $input-border-width-focused - $input-border-width-default * 2;
178+
padding-bottom: $input-border-width-focused - $input-border-width-default;
179+
border-bottom-width: $input-border-width-default;
161180
}
162181
}
163182

164183
.md-select-value {
165184
display: flex;
166185
align-items: center;
167186
padding: 2px 2px 1px;
168-
border-bottom-width: 1px;
187+
border-bottom-width: $select-border-width-default;
169188
border-bottom-style: solid;
170189
background-color: rgba(0,0,0,0);
171190
position: relative;
@@ -174,7 +193,6 @@ md-input-container.md-input-has-value .md-select-value {
174193
min-height: 26px;
175194
flex-grow: 1;
176195

177-
178196
> span:not(.md-select-icon) {
179197
max-width: 100%;
180198
flex: 1 1 auto;

0 commit comments

Comments
 (0)