Skip to content

Commit 4164751

Browse files
committed
fix(material/input): MatInput autofill styling only covers part of the displayed input
autofill attribute does not work properly with current styles and only covers the input/textarea box instead of all the form control fixes: #27337
1 parent 3da71ce commit 4164751

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

src/dev-app/input/input-demo.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,3 +977,39 @@ <h4>No defined label</h4>
977977
</p>
978978
</mat-card-content>
979979
</mat-card>
980+
981+
982+
<mat-card class="demo-card demo-basic">
983+
<mat-toolbar color="primary">Basic outlined/filled fields with autofill attribue</mat-toolbar>
984+
<mat-card-content>
985+
<form>
986+
<table style="width: 100%" cellspacing="0"><tr>
987+
<td>
988+
<mat-form-field style="width: 100%" appearance="outline">
989+
<input matInput placeholder="First name" autofill="given-name">
990+
</mat-form-field>
991+
</td>
992+
<td>
993+
<mat-form-field style="width: 100%" appearance="fill">
994+
<mat-label>Last name</mat-label>
995+
<input matInput autofill="family-name" placeholder="Last name">
996+
</mat-form-field>
997+
</td>
998+
</tr>
999+
<tr>
1000+
<td>
1001+
<mat-form-field style="width: 100%" appearance="outline">
1002+
<mat-label>Home Address</mat-label>
1003+
<textarea matInput autofill="address" placeholder="Home address"></textarea>
1004+
</mat-form-field>
1005+
</td>
1006+
<td>
1007+
<mat-form-field style="width: 100%" appearance="fill">
1008+
<mat-label>Shipping</mat-label>
1009+
<textarea matInput autofill="address" placeholder="Shipping address"></textarea>
1010+
</mat-form-field>
1011+
</td>
1012+
</tr></table>
1013+
</form>
1014+
</mat-card-content>
1015+
</mat-card>

src/material/form-field/form-field.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ $_icon-prefix-infix-padding: 4px;
186186
&:has(textarea[cols]) {
187187
width: auto;
188188
}
189+
190+
input:-webkit-autofill,
191+
textarea:-webkit-autofill {
192+
-webkit-background-clip: text;
193+
-webkit-text-fill-color: token-utils.slot(form-field-filled-input-text-color, $fallbacks);
194+
}
189195
}
190196

191197
// In the form-field theme, we add a 1px left margin to the notch to fix a rendering bug in Chrome.

0 commit comments

Comments
 (0)