Fix blurring inputs on Android
This commit is contained in:
parent
ab1e5920d5
commit
d8e8b91816
72
src/index.ts
72
src/index.ts
@ -61,14 +61,14 @@ console.timeEnd('get storage1'); */
|
|||||||
// We listen to the resize event (https://css-tricks.com/the-trick-to-viewport-units-on-mobile/)
|
// We listen to the resize event (https://css-tricks.com/the-trick-to-viewport-units-on-mobile/)
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const w = window.visualViewport || window; // * handle iOS keyboard
|
const w = window.visualViewport || window; // * handle iOS keyboard
|
||||||
let setViewportVH = false, hasFocus = false;
|
let setViewportVH = false/* , hasFocus = false */;
|
||||||
let lastVH: number;
|
let lastVH: number;
|
||||||
const setVH = () => {
|
const setVH = () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const vh = (setViewportVH && !rootScope.default.isOverlayActive ? w.height || w.innerHeight : window.innerHeight) * 0.01;
|
const vh = (setViewportVH && !rootScope.default.isOverlayActive ? w.height || w.innerHeight : window.innerHeight) * 0.01;
|
||||||
if(lastVH === vh) {
|
if(lastVH === vh) {
|
||||||
return;
|
return;
|
||||||
} else if(lastVH < vh && !hasFocus) {
|
} else if(touchSupport.isTouchSupported && lastVH < vh && (vh - lastVH) > 1) {
|
||||||
blurActiveElement(); // (Android) fix blurring inputs when keyboard is being closed (e.g. closing keyboard by back arrow and touching a bubble)
|
blurActiveElement(); // (Android) fix blurring inputs when keyboard is being closed (e.g. closing keyboard by back arrow and touching a bubble)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,9 +87,6 @@ console.timeEnd('get storage1'); */
|
|||||||
} */
|
} */
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('resize', setVH);
|
|
||||||
setVH();
|
|
||||||
|
|
||||||
// * hook worker constructor to set search parameters (test, debug, etc)
|
// * hook worker constructor to set search parameters (test, debug, etc)
|
||||||
const workerHandler = {
|
const workerHandler = {
|
||||||
construct(target: any, args: any) {
|
construct(target: any, args: any) {
|
||||||
@ -110,39 +107,45 @@ console.timeEnd('get storage1'); */
|
|||||||
import('./lib/rootScope'),
|
import('./lib/rootScope'),
|
||||||
import('./lib/appManagers/appStateManager'),
|
import('./lib/appManagers/appStateManager'),
|
||||||
import('./lib/langPack'),
|
import('./lib/langPack'),
|
||||||
])
|
]);
|
||||||
|
|
||||||
//console.timeEnd('get storage');
|
//console.timeEnd('get storage');
|
||||||
|
|
||||||
|
window.addEventListener('resize', setVH);
|
||||||
|
setVH();
|
||||||
|
|
||||||
//console.log(new Uint8Array([255, 200, 145]).hex);
|
//console.log(new Uint8Array([255, 200, 145]).hex);
|
||||||
|
|
||||||
const toggleResizeMode = () => {
|
if(IS_STICKY_INPUT_BUGGED) {
|
||||||
setViewportVH = tabId === 1 && IS_STICKY_INPUT_BUGGED && !rootScope.default.isOverlayActive;
|
const toggleResizeMode = () => {
|
||||||
setVH();
|
setViewportVH = tabId === 1 && IS_STICKY_INPUT_BUGGED && !rootScope.default.isOverlayActive;
|
||||||
|
setVH();
|
||||||
if(w !== window) {
|
|
||||||
if(setViewportVH) {
|
if(w !== window) {
|
||||||
window.removeEventListener('resize', setVH);
|
if(setViewportVH) {
|
||||||
w.addEventListener('resize', setVH);
|
window.removeEventListener('resize', setVH);
|
||||||
} else {
|
w.addEventListener('resize', setVH);
|
||||||
w.removeEventListener('resize', setVH);
|
} else {
|
||||||
window.addEventListener('resize', setVH);
|
w.removeEventListener('resize', setVH);
|
||||||
|
window.addEventListener('resize', setVH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
let tabId: number;
|
||||||
let tabId: number;
|
rootScope.default.addEventListener('im_tab_change', (id) => {
|
||||||
rootScope.default.addEventListener('im_tab_change', (id) => {
|
const wasTabId = tabId !== undefined;
|
||||||
const wasTabId = tabId !== undefined;
|
tabId = id;
|
||||||
tabId = id;
|
|
||||||
|
if(wasTabId || tabId === 1) {
|
||||||
if(wasTabId || tabId === 1) {
|
toggleResizeMode();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
rootScope.default.addEventListener('overlay_toggle', () => {
|
||||||
toggleResizeMode();
|
toggleResizeMode();
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
rootScope.default.addEventListener('overlay_toggle', () => {
|
|
||||||
toggleResizeMode();
|
|
||||||
});
|
|
||||||
|
|
||||||
if(userAgent.isFirefox && !IS_EMOJI_SUPPORTED) {
|
if(userAgent.isFirefox && !IS_EMOJI_SUPPORTED) {
|
||||||
document.addEventListener('dragstart', (e) => {
|
document.addEventListener('dragstart', (e) => {
|
||||||
@ -175,13 +178,14 @@ console.timeEnd('get storage1'); */
|
|||||||
} else if(userAgent.isAndroid) {
|
} else if(userAgent.isAndroid) {
|
||||||
document.documentElement.classList.add('is-android');
|
document.documentElement.classList.add('is-android');
|
||||||
|
|
||||||
document.addEventListener('focusin', () => {
|
/* document.addEventListener('focusin', (e) => {
|
||||||
hasFocus = true;
|
hasFocus = true;
|
||||||
|
focusTime = Date.now();
|
||||||
}, {passive: true});
|
}, {passive: true});
|
||||||
|
|
||||||
document.addEventListener('focusout', () => {
|
document.addEventListener('focusout', () => {
|
||||||
hasFocus = false;
|
hasFocus = false;
|
||||||
}, {passive: true});
|
}, {passive: true}); */
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!touchSupport.isTouchSupported) {
|
if(!touchSupport.isTouchSupported) {
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* https://github.com/morethanwords/tweb
|
||||||
|
* Copyright (C) 2019-2021 Eduard Kuzmenko
|
||||||
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
.popup-report-messages-confirm {
|
.popup-report-messages-confirm {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user