From 6550be3719b08e296ff7cfa662bb97e7970435b6 Mon Sep 17 00:00:00 2001 From: Alexander Shabunevich Date: Fri, 4 Oct 2024 17:59:05 +0300 Subject: [PATCH] fix: safari autofill bug Safari doesn't fire input event on autofill of the fields like phone. But there is a custom event with e.bubbles = true and on our own custom event e.bubbles = false. So we can filter Safari autofill event for the correct mask processing. --- src/input.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/input.ts b/src/input.ts index c78ebca..724e235 100644 --- a/src/input.ts +++ b/src/input.ts @@ -76,7 +76,8 @@ export class MaskInput { private readonly onInput = (e: Event | InputEvent): void => { // check both CustomEvent and isTrusted https://github.com/beholdr/maska/issues/227 - if (e instanceof CustomEvent && e.type === 'input' && !e.isTrusted) { + // also check for bubbles because of Safari autofill bug https://github.com/beholdr/maska/issues/238 + if (e instanceof CustomEvent && e.type === 'input' && !e.isTrusted && !e.bubbles) { return }