Skip to content

Commit 3955555

Browse files
committed
move border to its own div; make value ellipsis
1 parent 9ec0517 commit 3955555

File tree

3 files changed

+38
-12
lines changed

3 files changed

+38
-12
lines changed

src/lib/select/_select-theme.scss

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,25 @@
99

1010
.mat-select-trigger {
1111
color: mat-color($foreground, hint-text);
12-
border-bottom: 1px solid mat-color($foreground, divider);
1312

1413
.mat-select:focus:not(.mat-select-disabled) & {
1514
color: mat-color($primary);
16-
border-bottom: 1px solid mat-color($primary);
1715
}
1816

1917
.mat-select.ng-invalid.ng-touched:not(.mat-select-disabled) & {
2018
color: mat-color($warn);
21-
border-bottom: 1px solid mat-color($warn);
19+
}
20+
}
21+
22+
.mat-select-border {
23+
background-color: mat-color($foreground, divider);
24+
25+
.mat-select:focus:not(.mat-select-disabled) & {
26+
background-color: mat-color($primary);
27+
}
28+
29+
.mat-select.ng-invalid.ng-touched:not(.mat-select-disabled) & {
30+
background-color: mat-color($warn);
2231
}
2332
}
2433

src/lib/select/select.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<div class="mat-select-trigger" cdk-overlay-origin (click)="toggle()" #origin="cdkOverlayOrigin" #trigger>
22
<span class="mat-select-placeholder" [class.mat-floating-placeholder]="this.selected"
33
[@transformPlaceholder]="_placeholderState" [style.width.px]="_selectedValueWidth"> {{ placeholder }} </span>
4-
<span class="mat-select-value" *ngIf="selected"> {{ selected?.viewValue }} </span>
4+
<span class="mat-select-value" *ngIf="selected">
5+
<span class="mat-select-value-text">{{ selected?.viewValue }}</span>
6+
</span>
57
<span class="mat-select-arrow"></span>
8+
<span class="mat-select-border"></span>
69
</div>
710

811
<template cdk-connected-overlay [origin]="origin" [open]="panelOpen" hasBackdrop (backdropClick)="close()"

src/lib/select/select.scss

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,28 @@ $mat-select-panel-max-height: 256px !default;
2222
min-width: $mat-select-trigger-min-width;
2323
cursor: pointer;
2424
position: relative;
25-
box-sizing: border-box;
2625

2726
[aria-disabled='true'] & {
28-
@include mat-control-disabled-underline();
29-
border-bottom: transparent;
3027
background-position: 0 bottom;
3128
cursor: default;
3229
user-select: none;
3330
}
3431
}
3532

33+
.mat-select-border {
34+
position: absolute;
35+
bottom: 0;
36+
left: 0;
37+
right: 0;
38+
height: 1px;
39+
40+
[aria-disabled='true'] & {
41+
@include mat-control-disabled-underline();
42+
background-color: transparent;
43+
background-position: 0 bottom;
44+
}
45+
}
46+
3647
.mat-select-placeholder {
3748
position: relative;
3849
padding: 0 2px;
@@ -65,7 +76,6 @@ $mat-select-panel-max-height: 256px !default;
6576
}
6677

6778
.mat-select-value {
68-
@include mat-truncate-line();
6979
position: absolute;
7080
max-width: calc(100% - #{$mat-select-arrow-size * 2});
7181

@@ -74,13 +84,12 @@ $mat-select-panel-max-height: 256px !default;
7484
// position. This has been fixed for Firefox 52, slated for early 2017.
7585
// Bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=874718
7686
//
77-
// In the meantime, we must adjust the position to fit the top and left edge of the
78-
// containing element with a height matching the trigger container.
79-
// In doing so, we can use align-items: center to allow the text to
87+
// In the meantime, we must adjust the position to fit the top, left, and bottom edge of the
88+
// containing trigger element. In doing so, we can use align-items: center to allow the text to
8089
// correctly position itself in the middle of the container.
8190
top: 0;
8291
left: 0;
83-
height: $mat-select-trigger-height;
92+
bottom: 0;
8493

8594
display: flex;
8695
align-items: center;
@@ -91,6 +100,11 @@ $mat-select-panel-max-height: 256px !default;
91100
}
92101
}
93102

103+
.mat-select-value-text {
104+
@include mat-truncate-line();
105+
line-height: $mat-select-trigger-height;
106+
}
107+
94108
.mat-select-arrow {
95109
width: 0;
96110
height: 0;

0 commit comments

Comments
 (0)