Skip to content

Commit 48a8180

Browse files
fix(masked-input): Value not committed on auto-fill behavior (#1932)
* fix(masked-input): Value not commited on auto-fill behavior * chore: Added storybook sample reproducing the issue * refactor(input): autofill styles * remove(datepicker): Autofill story --------- Co-authored-by: Simeon Simeonoff <[email protected]>
1 parent 9743742 commit 48a8180

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/components/date-picker/date-picker.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,6 @@ describe('Date picker', () => {
969969

970970
it('issue 1884 - should emit igcChange event in dialog mode after clearing the value and losing focus', async () => {
971971
const eventSpy = spy(picker, 'emitEvent');
972-
// const nativeInput = dateTimeInput.renderRoot.querySelector('input')!;
973972

974973
// Dropdown mode
975974

src/components/input/themes/input.base.scss

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,8 @@
4545
// This is a hack that removes the autofill background and it's essential,
4646
// otherwise the background is on top of the floating label in material theme.
4747
// The !important flag is because themes that defin transition delay on that element are overriding the transition delay hack
48-
&:-webkit-autofill,
49-
&:-webkit-autofill:hover,
50-
&:-webkit-autofill:focus,
51-
&:-webkit-autofill:active,
52-
&:autofill,
53-
&:autofill:hover,
54-
&:autofill:focus,
55-
&:autofill:active{
48+
&:is(:-webkit-autofill, :autofill) {
49+
transition-property: background-color, color !important;
5650
transition-delay: 99999s !important;
5751
}
5852
}

src/components/mask-input/mask-input-base.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ export abstract class IgcMaskInputBaseComponent extends IgcInputBaseComponent {
116116
value.substring(this._inputSelection.start, this._inputSelection.end),
117117
{ ...this._inputSelection }
118118
);
119+
120+
// Potential browser auto-fill behavior
121+
case undefined:
122+
return this._updateInput(
123+
value.substring(start, this._inputSelection.end),
124+
{
125+
start,
126+
end: this._inputSelection.end,
127+
}
128+
);
119129
}
120130
}
121131

0 commit comments

Comments
 (0)