From 66c5dd10dc3b75a645b17c5b06b193483c026a89 Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Thu, 12 Sep 2024 11:52:01 -0400 Subject: [PATCH] fix(core): fix mobile input blur on touchstart on different input fixes #7728 --- src/core/events/onTouchMove.mjs | 9 ++++++++- src/core/events/onTouchStart.mjs | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/events/onTouchMove.mjs b/src/core/events/onTouchMove.mjs index 85a23f4c6..7c8dd5deb 100644 --- a/src/core/events/onTouchMove.mjs +++ b/src/core/events/onTouchMove.mjs @@ -76,7 +76,14 @@ export default function onTouchMove(event) { return; } } - + if ( + document.activeElement && + document.activeElement.matches(data.focusableElements) && + document.activeElement !== e.target && + e.pointerType !== 'mouse' + ) { + document.activeElement.blur(); + } if (document.activeElement) { if (e.target === document.activeElement && e.target.matches(data.focusableElements)) { data.isMoved = true; diff --git a/src/core/events/onTouchStart.mjs b/src/core/events/onTouchStart.mjs index c4396b0d0..dc52cee6a 100644 --- a/src/core/events/onTouchStart.mjs +++ b/src/core/events/onTouchStart.mjs @@ -134,10 +134,13 @@ export default function onTouchStart(event) { data.isTouched = false; } } + if ( document.activeElement && document.activeElement.matches(data.focusableElements) && - document.activeElement !== targetEl + document.activeElement !== targetEl && + (e.pointerType === 'mouse' || + (e.pointerType !== 'mouse' && !targetEl.matches(data.focusableElements))) ) { document.activeElement.blur(); }