Skip to content

Commit 166279b

Browse files
crisbetommalerba
authored andcommittedDec 3, 2018
fix(form-field): long labels and option values going under select arrow (#14268)
Fixes very long form field labels and option value colliding with the arrow that is rendered next to a `select` inside a `mat-form-field`.
1 parent dd6065c commit 166279b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
 

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

+16
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,22 @@ select.mat-input-element {
193193
}
194194
}
195195

196+
.mat-input-element {
197+
// The arrow is 2 * $arrow-size wide and we add one more width for some spacing.
198+
$padding: $arrow-size * 3;
199+
padding-right: $padding;
200+
201+
[dir='rtl'] & {
202+
padding-right: 0;
203+
padding-left: $padding;
204+
}
205+
}
206+
207+
// Ensure that long labels don't collide with the select arrow.
208+
.mat-form-field-label-wrapper {
209+
max-width: calc(100% - #{$arrow-size * 2});
210+
}
211+
196212
&.mat-form-field-appearance-outline .mat-form-field-infix::after {
197213
margin-top: -$arrow-size;
198214
}

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

+7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ $mat-form-field-default-infix-width: 180px !default;
7373
height: 100%;
7474
overflow: hidden;
7575
pointer-events: none; // We shouldn't catch mouse events (let them through).
76+
77+
[dir='rtl'] & {
78+
// Usually this isn't necessary since the element is 100% wide, but
79+
// when we've got a `select` node, we need to set a `max-width` on it.
80+
left: auto;
81+
right: 0;
82+
}
7683
}
7784

7885
// The label itself. This is invisible unless it is. The logic to show it is

0 commit comments

Comments
 (0)
Please sign in to comment.