Browse Source

Fix blurring inputs on Android

master
Eduard Kuzmenko 3 years ago
parent
commit
d8e8b91816
  1. 20
      src/index.ts
  2. 6
      src/scss/partials/popups/_reportMessages.scss

20
src/index.ts

@ -61,14 +61,14 @@ console.timeEnd('get storage1'); */ @@ -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/)
// @ts-ignore
const w = window.visualViewport || window; // * handle iOS keyboard
let setViewportVH = false, hasFocus = false;
let setViewportVH = false/* , hasFocus = false */;
let lastVH: number;
const setVH = () => {
// @ts-ignore
const vh = (setViewportVH && !rootScope.default.isOverlayActive ? w.height || w.innerHeight : window.innerHeight) * 0.01;
if(lastVH === vh) {
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)
}
@ -87,9 +87,6 @@ console.timeEnd('get storage1'); */ @@ -87,9 +87,6 @@ console.timeEnd('get storage1'); */
} */
};
window.addEventListener('resize', setVH);
setVH();
// * hook worker constructor to set search parameters (test, debug, etc)
const workerHandler = {
construct(target: any, args: any) {
@ -110,11 +107,16 @@ console.timeEnd('get storage1'); */ @@ -110,11 +107,16 @@ console.timeEnd('get storage1'); */
import('./lib/rootScope'),
import('./lib/appManagers/appStateManager'),
import('./lib/langPack'),
])
]);
//console.timeEnd('get storage');
window.addEventListener('resize', setVH);
setVH();
//console.log(new Uint8Array([255, 200, 145]).hex);
if(IS_STICKY_INPUT_BUGGED) {
const toggleResizeMode = () => {
setViewportVH = tabId === 1 && IS_STICKY_INPUT_BUGGED && !rootScope.default.isOverlayActive;
setVH();
@ -143,6 +145,7 @@ console.timeEnd('get storage1'); */ @@ -143,6 +145,7 @@ console.timeEnd('get storage1'); */
rootScope.default.addEventListener('overlay_toggle', () => {
toggleResizeMode();
});
}
if(userAgent.isFirefox && !IS_EMOJI_SUPPORTED) {
document.addEventListener('dragstart', (e) => {
@ -175,13 +178,14 @@ console.timeEnd('get storage1'); */ @@ -175,13 +178,14 @@ console.timeEnd('get storage1'); */
} else if(userAgent.isAndroid) {
document.documentElement.classList.add('is-android');
document.addEventListener('focusin', () => {
/* document.addEventListener('focusin', (e) => {
hasFocus = true;
focusTime = Date.now();
}, {passive: true});
document.addEventListener('focusout', () => {
hasFocus = false;
}, {passive: true});
}, {passive: true}); */
}
if(!touchSupport.isTouchSupported) {

6
src/scss/partials/popups/_reportMessages.scss

@ -1,3 +1,9 @@ @@ -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 {
user-select: none;

Loading…
Cancel
Save