Skip to content

Commit 1f8da0b

Browse files
committed
tweak select styles to fit form-field
1 parent 4e9bdf9 commit 1f8da0b

File tree

3 files changed

+12
-28
lines changed

3 files changed

+12
-28
lines changed

src/lib/form-field/form-field.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ $mat-form-field-underline-height: 1px !default;
6060
display: block;
6161
position: relative;
6262
flex: auto;
63+
min-width: 0;
6364
}
6465

6566
// Pseudo-class for Chrome and Safari auto-fill to move the placeholder to the floating position.

src/lib/select/_select-theme.scss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,14 @@
6060
}
6161

6262
@mixin mat-select-typography($config) {
63-
$trigger-font-size: mat-font-size($config, subheading-2);
63+
// The unit-less line-height from the font config.
64+
$line-height: mat-line-height($config, input);
6465

6566
.mat-select {
66-
// Reserve enough space for the floating placeholder.
67-
padding-top: $trigger-font-size;
6867
font-family: mat-font-family($config);
6968
}
7069

7170
.mat-select-trigger {
72-
font-size: $trigger-font-size;
71+
height: $line-height * 1em;
7372
}
7473
}

src/lib/select/select.scss

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
@import '../core/style/vendor-prefixes';
55
@import '../core/a11y/a11y';
66

7-
$mat-select-trigger-height: 30px !default;
87
$mat-select-trigger-min-width: 112px !default;
98
$mat-select-arrow-size: 5px !default;
109
$mat-select-arrow-margin: 4px !default;
@@ -13,12 +12,17 @@ $mat-select-panel-max-height: 256px !default;
1312
.mat-select {
1413
display: inline-block;
1514
outline: none;
15+
16+
// Inside of a form field we want it to expand to take the available space.
17+
.mat-form-field & {
18+
display: block;
19+
width: 100%;
20+
}
1621
}
1722

1823
.mat-select-trigger {
1924
display: flex;
2025
align-items: center;
21-
height: $mat-select-trigger-height;
2226
min-width: $mat-select-trigger-min-width;
2327
cursor: pointer;
2428
position: relative;
@@ -31,34 +35,14 @@ $mat-select-panel-max-height: 256px !default;
3135
}
3236

3337
.mat-select-value {
34-
position: absolute;
35-
max-width: calc(100% - #{($mat-select-arrow-size + $mat-select-arrow-margin) * 2});
36-
flex-grow: 1;
37-
38-
// Firefox and some versions of IE incorrectly keep absolutely
39-
// positioned children of flex containers in the flex flow when calculating
40-
// position. This has been fixed for Firefox 52, slated for early 2017.
41-
// Bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=874718
42-
//
43-
// In the meantime, we must adjust the position to fit the top, left, and bottom edge of the
44-
// containing trigger element. In doing so, we can use align-items: center to allow the text to
45-
// correctly position itself in the middle of the container.
46-
top: 0;
47-
left: 0;
48-
bottom: 0;
49-
5038
display: flex;
39+
flex: auto;
5140
align-items: center;
52-
53-
[dir='rtl'] & {
54-
left: auto;
55-
right: 0;
56-
}
41+
min-width: 0;
5742
}
5843

5944
.mat-select-value-text {
6045
@include mat-truncate-line();
61-
line-height: $mat-select-trigger-height;
6246
}
6347

6448
.mat-select-arrow {

0 commit comments

Comments
 (0)