Skip to content

Commit

Permalink
fix(core): correct handling of browser autofill/suggestion in Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
nsbarsukov committed Jun 21, 2024
1 parent 8345027 commit 1c37a2f
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit 1c37a2f

Please sign in to comment.