Skip to content

Commit 2f6874a

Browse files
fix(input-group): fix browser autofill issue (#15823)
Co-authored-by: Simeon Simeonoff <[email protected]>
1 parent edb5404 commit 2f6874a

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed

projects/igniteui-angular/src/lib/core/styles/components/input/_input-group-component.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
@include e(input) {
5353
@extend %form-group-input !optional;
54-
@extend %chrome-autofill-fix !optional;
54+
@extend %autofill-background-fix !optional;
5555
@extend %edge-clear-icon-fix !optional;
5656

5757
&:hover {
@@ -421,6 +421,7 @@
421421

422422
// Type border START
423423
@include m(border) {
424+
@extend %form-group-display--border !optional;
424425
@extend %form-group-display--no-margin !optional;
425426

426427
@include e(bundle) {

projects/igniteui-angular/src/lib/core/styles/components/input/_input-group-theme.scss

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,25 @@
394394
}
395395
}
396396

397+
@if $variant == 'material' {
398+
%form-group-display--border {
399+
&:has(input:-webkit-autofill, input:autofill) {
400+
%igx-input-group__notch--border {
401+
border-block-start-color: transparent;
402+
}
403+
404+
%form-group-label {
405+
--label-position: #{sizable(18px, 22px, 26px)};
406+
407+
transform: translateY(calc(var(--label-position) * -1));
408+
margin-top: 0;
409+
overflow: hidden;
410+
will-change: font-size, color, transform;
411+
}
412+
}
413+
}
414+
}
415+
397416
%form-group-display--box {
398417
%form-group-border {
399418
margin-bottom: 0;
@@ -464,6 +483,20 @@
464483
--size: var(--input-icon) !important;
465484
}
466485
}
486+
487+
@if $variant == 'material' {
488+
&:not(%form-group-display--border) {
489+
&:has(input:-webkit-autofill, input:autofill) {
490+
%form-group-label {
491+
--floating-label-position: -73%;
492+
493+
@include type-style('caption');
494+
495+
transform: translateY(var(--floating-label-position));
496+
}
497+
}
498+
}
499+
}
467500
}
468501

469502
%form-group-placeholder {
@@ -1234,13 +1267,20 @@
12341267
}
12351268
}
12361269

1237-
%chrome-autofill-fix {
1270+
// This is a hack that removes the autofill background and it's essential,
1271+
// otherwise the background is on top of the floating label in material theme.
1272+
// The !important flag is because bootstrap theme(and potentially feature themes) is overriding the transition delay.
1273+
%autofill-background-fix {
12381274
&:-webkit-autofill,
12391275
&:-webkit-autofill:hover,
12401276
&:-webkit-autofill:focus,
1241-
&:-webkit-autofill:active {
1242-
-webkit-transition-delay: 99999s;
1243-
transition-delay: 99999s;
1277+
&:-webkit-autofill:active,
1278+
&:autofill,
1279+
&:autofill:hover,
1280+
&:autofill:focus,
1281+
&:autofill:active, {
1282+
-webkit-transition-delay: 99999s !important;
1283+
transition-delay: 99999s !important;
12441284
}
12451285
}
12461286

@@ -2092,7 +2132,15 @@
20922132
map.get($bootstrap-inline-padding, 'cosy'),
20932133
map.get($bootstrap-inline-padding, 'comfortable')
20942134
);
2095-
transition: box-shadow .15s ease-out, border .15s ease-out;
2135+
}
2136+
2137+
// The :not selector is needed otherwise bootstrap will override the %autofill-background-fix
2138+
%form-group-display--bootstrap {
2139+
:not(:has(input:-webkit-autofill, input:autofill)) {
2140+
%bootstrap-input {
2141+
transition: box-shadow .15s ease-out, border .15s ease-out;
2142+
}
2143+
}
20962144
}
20972145

20982146
%bootstrap-input,

0 commit comments

Comments
 (0)