Skip to content

Commit 0f7d503

Browse files
mmalerbajosephperrott
authored andcommitted
fix(form-field): inconsistent underline height at different DPIs (#11062)
1 parent 340b0b2 commit 0f7d503

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/lib/core/style/_form-common.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// to match the Material Design spec.
66
@mixin mat-control-disabled-underline($color) {
77
background-image: linear-gradient(to right, $color 0%, $color 33%, transparent 0%);
8-
background-size: 4px 1px;
8+
background-size: 4px 100%;
99
background-repeat: repeat-x;
1010
}
1111

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ $mat-form-field-default-infix-width: 180px !default;
144144
width: 100%;
145145
// Need this so that the underline doesn't block the hover effect.
146146
pointer-events: none;
147+
// We transform the height slightly higher to fix inconsistent underline height for some DPIs.
148+
// Without this we observed that at zoom levels between 50% and 100% some form-field underlines
149+
// would disappear. The issue appears to be related to fractional pixels since (e.g. underlines
150+
// with their top at x.6 would disappear, but ones with there top at x.7 were fine). The exact
151+
// fractions that caused problems seemed to depend on the screen resolution and zoom level. We
152+
// experimentally discovered that adding a very slight scale factor fixes the issue.
153+
transform: scaleY(1.0001);
147154
}
148155

149156
.mat-form-field-ripple {

0 commit comments

Comments
 (0)