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(); }