Skip to content

Commit 610da48

Browse files
authored
fix(input-group): fix browser autofill issue (#15821)
1 parent 310d1ba commit 610da48

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 {
@@ -403,6 +403,7 @@
403403

404404
// Type border START
405405
@include m(border) {
406+
@extend %form-group-display--border !optional;
406407
@extend %form-group-display--no-margin !optional;
407408

408409
@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
@@ -393,6 +393,25 @@
393393
}
394394
}
395395

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

468501
%form-group-placeholder {
@@ -1179,13 +1212,20 @@
11791212
}
11801213
}
11811214

1182-
%chrome-autofill-fix {
1215+
// This is a hack that removes the autofill background and it's essential,
1216+
// otherwise the background is on top of the floating label in material theme.
1217+
// The !important flag is because bootstrap theme(and potentially feature themes) is overriding the transition delay.
1218+
%autofill-background-fix {
11831219
&:-webkit-autofill,
11841220
&:-webkit-autofill:hover,
11851221
&:-webkit-autofill:focus,
1186-
&:-webkit-autofill:active {
1187-
-webkit-transition-delay: 99999s;
1188-
transition-delay: 99999s;
1222+
&:-webkit-autofill:active,
1223+
&:autofill,
1224+
&:autofill:hover,
1225+
&:autofill:focus,
1226+
&:autofill:active, {
1227+
-webkit-transition-delay: 99999s !important;
1228+
transition-delay: 99999s !important;
11891229
}
11901230
}
11911231

@@ -1980,7 +2020,15 @@
19802020
map.get($bootstrap-inline-padding, 'cosy'),
19812021
map.get($bootstrap-inline-padding, 'comfortable')
19822022
);
1983-
transition: box-shadow .15s ease-out, border .15s ease-out;
2023+
}
2024+
2025+
// The :not selector is needed otherwise bootstrap will override the %autofill-background-fix
2026+
%form-group-display--bootstrap {
2027+
:not(:has(input:-webkit-autofill, input:autofill)) {
2028+
%bootstrap-input {
2029+
transition: box-shadow .15s ease-out, border .15s ease-out;
2030+
}
2031+
}
19842032
}
19852033

19862034
%bootstrap-input,

0 commit comments

Comments
 (0)