Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): correct handling of browser autofill/suggestion in Firefox #1326

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions projects/core/src/lib/mask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ export class Maskito extends MaskHistory {
});
case 'insertCompositionText':
return; // will be handled inside `compositionend` event
case 'insertReplacementText':
/**
* According {@link https://www.w3.org/TR/input-events-2 W3C specification}:
* > `insertReplacementText` – insert or replace existing text by means of a spell checker,
* > auto-correct, writing suggestions or similar.
* ___
* Firefox emits `insertReplacementText` event for its suggestion/autofill and for spell checker.
* However, it is impossible to detect which part of the textfield value is going to be replaced
* (`selectionStart` and `selectionEnd` just equal to the last caret position).
* ___
* Chrome does not fire `beforeinput` event for its suggestion/autofill.
* It emits only `input` event with `inputType` and `data` set to `undefined`.
* ___
* All these browser limitations make us to validate the result value later in `input` event.
*/
return;
case 'insertLineBreak':
case 'insertParagraph':
return this.handleEnter(event);
Expand Down
Loading