Skip to content

Commit bb61885

Browse files
committed
fix: add transition to placeholder text
1 parent 1c283b1 commit bb61885

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/lib/input/input.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
display: none;
3838
}
3939

40+
@include input-placeholder {
41+
// Delay the transition until the label has animated about a third of the way through, in
42+
// order to prevent the placeholder from overlapping for a split second.
43+
transition: color $swift-ease-out-duration $swift-ease-out-duration / 3
44+
$swift-ease-out-timing-function;
45+
}
46+
4047
.mat-form-field-hide-placeholder & {
4148
// Note that we can't use something like visibility: hidden or
4249
// display: none, because IE ends up preventing the user from
@@ -45,6 +52,10 @@
4552
// Needs to be !important, because the placeholder will end up inheriting the
4653
// input color in IE, if the consumer overrides it with a higher specificity.
4754
color: transparent !important;
55+
56+
// Remove the transition to prevent the placeholder
57+
// from overlapping when the label comes back down.
58+
transition: none;
4859
}
4960
}
5061
}

src/lib/select/select.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,16 @@ $mat-select-placeholder-arrow-space: 2 * ($mat-select-arrow-size + $mat-select-a
8989
}
9090

9191
.mat-select-placeholder {
92+
// Delay the transition until the label has animated about a third of the way through, in
93+
// order to prevent the placeholder from overlapping for a split second.
94+
transition: color $swift-ease-out-duration $swift-ease-out-duration / 3
95+
$swift-ease-out-timing-function;
96+
9297
.mat-form-field-hide-placeholder & {
9398
color: transparent;
99+
100+
// Remove the transition to prevent the placeholder
101+
// from overlapping when the label comes back down.
102+
transition: none;
94103
}
95104
}

0 commit comments

Comments
 (0)