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

Commit 2e21356

Browse files
committed
fix(select) rework select to match Material Design spec
automatic 16px horizontal margin when in row layout add md-inline-form support
1 parent 39911d3 commit 2e21356

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

src/components/select/select.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,9 +1493,9 @@ function SelectProvider($$interimElementProvider) {
14931493
transformOrigin = '50% 100%';
14941494
}
14951495
} else {
1496-
left = (targetRect.left + centeredRect.left - centeredRect.paddingLeft) + 2;
1496+
left = (targetRect.left + centeredRect.left - centeredRect.paddingLeft);
14971497
top = Math.floor(targetRect.top + targetRect.height / 2 - centeredRect.height / 2 -
1498-
centeredRect.top + contentNode.scrollTop) + 2;
1498+
centeredRect.top + contentNode.scrollTop) + 1;
14991499

15001500
transformOrigin = (centeredRect.left + targetRect.width / 2) + 'px ' +
15011501
(centeredRect.top + centeredRect.height / 2 - contentNode.scrollTop) + 'px 0px';

src/components/select/select.scss

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ $select-max-visible-options: 5 !default;
5252
}
5353

5454
md-input-container > md-select {
55-
margin: 0;
5655
order: 2;
56+
margin-top: -7px; // Align with md-input-container
5757
}
5858

5959
md-select {
6060
display: flex;
61-
margin: 2.5*$baseline-grid 0 3*$baseline-grid + 2 0;
61+
margin: 0;
6262
&[disabled] ._md-select-value {
6363
background-position: 0 bottom;
6464
// This background-size is coordinated with a linear-gradient set in select-theme.scss
@@ -80,14 +80,14 @@ md-select {
8080
&.ng-invalid.ng-dirty {
8181
._md-select-value {
8282
border-bottom: 2px solid;
83-
padding-bottom: 0;
83+
padding-bottom: 5px;
8484
}
8585
}
8686
&:focus {
8787
._md-select-value {
8888
border-bottom-width: 2px;
8989
border-bottom-style: solid;
90-
padding-bottom: 0;
90+
padding-bottom: 5px;
9191
}
9292
}
9393
}
@@ -97,14 +97,16 @@ md-select {
9797
._md-select-value {
9898
display: flex;
9999
align-items: center;
100-
padding: 2px 2px 1px;
100+
padding: 4px 0 6px 0;
101101
border-bottom-width: 1px;
102102
border-bottom-style: solid;
103103
background-color: rgba(0,0,0,0);
104104
position: relative;
105105
box-sizing: content-box;
106-
min-width: 8 * $baseline-grid;
106+
min-width: 11 * $baseline-grid;
107107
min-height: 26px;
108+
margin-bottom: auto;
109+
-ms-flex-item-align: start; // workaround for margin-bottom: auto
108110
flex-grow: 1;
109111

110112

@@ -134,17 +136,17 @@ md-select {
134136
display: block;
135137
content: '\25BC';
136138
position: relative;
137-
top: 2px;
139+
right: -7px;
140+
top: 1px;
138141
speak: none;
139-
transform: scaleY(0.6) scaleX(1);
142+
transform: scaleY(0.5);
140143
}
141144

142145
&._md-select-placeholder {
143146
display: flex;
144147
order: 1;
145148
pointer-events: none;
146149
-webkit-font-smoothing: antialiased;
147-
padding-left: 2px;
148150
z-index: 1;
149151
}
150152
}
@@ -248,3 +250,20 @@ md-select-menu[multiple] {
248250
}
249251
}
250252
}
253+
254+
.layout-row,
255+
.layout-xs-row, .layout-gt-xs-row,
256+
.layout-sm-row, .layout-gt-sm-row,
257+
.layout-md-row, .layout-gt-md-row,
258+
.layout-lg-row, .layout-gt-lg-row,
259+
.layout-xl-row {
260+
& > md-select:not(:last-child), {
261+
@include rtl(margin-left, 0, $select-container-padding);
262+
@include rtl(margin-right, $select-container-padding, 0);
263+
}
264+
265+
.md-inline-form & > md-select {
266+
margin-top: 13px;
267+
margin-bottom: auto;
268+
}
269+
}

0 commit comments

Comments
 (0)