Fix unfocusing input on Android

This commit is contained in:
Eduard Kuzmenko 2023-02-06 16:04:21 +04:00
parent 992ec48451
commit b0fa1c2d43
1 changed files with 23 additions and 6 deletions

View File

@ -189,14 +189,31 @@ document.addEventListener('DOMContentLoaded', async() => {
} else if(IS_ANDROID) {
document.documentElement.classList.add('is-android');
/* document.addEventListener('focusin', (e) => {
hasFocus = true;
focusTime = Date.now();
}, {passive: true});
// force losing focus on input blur
// focusin and focusout are not working on mobile
document.addEventListener('focusout', () => {
const onInResize = () => {
hasFocus = true;
window.addEventListener('resize', onOutResize, {once: true});
};
const onOutResize = () => {
hasFocus = false;
}, {passive: true}); */
blurActiveElement();
};
let hasFocus = false;
document.addEventListener('touchend', (e) => {
const input = (e.target as HTMLElement).closest('[contenteditable="true"], input');
if(!input) {
return;
}
if(document.activeElement !== input && !hasFocus) {
console.log('input click', e, document.activeElement, input, input.matches(':focus'));
window.addEventListener('resize', onInResize, {once: true});
}
});
}
if(!IS_TOUCH_SUPPORTED) {