fix(mobile): keyboard via VisualViewport (device-independent) + temp debug readout

Replace the hardcoded factor with the real overlap = clientHeight - visualViewport.height (works on any
screen). Adds a temporary on-screen debug line to confirm which signal the device reports, so the final
logic needs no per-device tuning. Debug removed once confirmed.
Build marker -> 2026-07-18-batch104.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-18 01:25:10 +05:30
parent c5489d7ad6
commit 8867d0abfc
+15 -11
View File
@@ -1112,7 +1112,7 @@
</head> </head>
<body> <body>
<script src="/icons.js?v=6"></script> <script src="/icons.js?v=6"></script>
<script>window.__BUILD='2026-07-18-batch103';console.log('%cBiz Connect','color:#1F3B73;font-weight:bold','build '+window.__BUILD); <script>window.__BUILD='2026-07-18-batch104';console.log('%cBiz Connect','color:#1F3B73;font-weight:bold','build '+window.__BUILD);
// Emoji are rendered with the OS's own (colour) emoji font — instant, zero network. // Emoji are rendered with the OS's own (colour) emoji font — instant, zero network.
// //
// We used to run Twemoji over every emoji, which swapped each one for an <img> pulled INDIVIDUALLY from // We used to run Twemoji over every emoji, which swapped each one for an <img> pulled INDIVIDUALLY from
@@ -1127,19 +1127,23 @@ function twemojify(_el){ /* native emoji: nothing to do */ }</script>
// juggling here — we only tag <html> so CSS can make small native-only tweaks if needed. // juggling here — we only tag <html> so CSS can make small native-only tweaks if needed.
(function(){ try{ var C=window.Capacitor; if(!C||!C.isNativePlatform||!C.isNativePlatform()) return; (function(){ try{ var C=window.Capacitor; if(!C||!C.isNativePlatform||!C.isNativePlatform()) return;
var p=(C.getPlatform&&C.getPlatform())||''; var r=document.documentElement; r.classList.add('native-app'); if(p) r.classList.add('native-'+p); var p=(C.getPlatform&&C.getPlatform())||''; var r=document.documentElement; r.classList.add('native-app'); if(p) r.classList.add('native-'+p);
// Keyboard: with resize:none the WebView never resizes, so we raise the composer by the keyboard height. // Keyboard — DEVICE-INDEPENDENT: the real keyboard overlap is (layout viewport height - visible viewport
// The plugin reports that height in DEVICE PIXELS on some builds, but CSS wants points — so a raw value // height), read from the VisualViewport API. No per-device factor. We prefer that; only if the WebView
// bigger than the screen's point height is divided by devicePixelRatio. This normalization makes it land // doesn't reflect the keyboard in VisualViewport do we fall back to the plugin's reported height.
// exactly on the keyboard regardless of unit. function kbFromVV(){ var vv=window.visualViewport; if(!vv) return 0; return Math.max(0, Math.round(document.documentElement.clientHeight - vv.height - vv.offsetTop)); }
// Measured on-device: the plugin's reported height puts the composer ~2x too high, so scale it. This is function applyKb(px){ px=Math.max(0,Math.round(px)); r.style.setProperty('--kb',px+'px'); document.body.classList.toggle('kb-open',px>4); if(px>4){ var b=document.getElementById('msgs'); if(b) b.scrollTop=b.scrollHeight; } }
// a single tunable number — if the composer isn't flush on the keyboard, nudge KB_FACTOR up/down. // TEMP one-time debug readout (remove once logic is locked): shows the raw signals at the top of screen.
var KB_FACTOR=0.52; var dbg=document.createElement('div'); var lastRaw=null;
function bzKbHeight(raw){ raw=raw||0; var dpr=window.devicePixelRatio||1; var norm = raw > window.innerHeight ? raw/dpr : raw; return Math.round(norm*KB_FACTOR); } dbg.style.cssText='position:fixed;left:0;right:0;top:0;z-index:2147483647;background:rgba(0,0,0,.82);color:#0f0;font:11px/1.35 monospace;padding:3px 6px;text-align:center;pointer-events:none;';
function rd(){ var vv=window.visualViewport; dbg.textContent='kbRaw='+(lastRaw==null?'-':Math.round(lastRaw))+' innerH='+window.innerHeight+' clientH='+document.documentElement.clientHeight+' vvH='+(vv?Math.round(vv.height):'-')+' vvTop='+(vv?Math.round(vv.offsetTop):'-')+' dpr='+window.devicePixelRatio+' -> vvKb='+kbFromVV(); }
if(document.body){ document.body.appendChild(dbg); } else { document.addEventListener('DOMContentLoaded', function(){ document.body.appendChild(dbg); }); }
if(window.visualViewport){ ['resize','scroll'].forEach(function(ev){ window.visualViewport.addEventListener(ev, function(){ var k=kbFromVV(); if(k>20) applyKb(k); rd(); }); }); }
var KB=C.Plugins&&C.Plugins.Keyboard; var KB=C.Plugins&&C.Plugins.Keyboard;
if(KB && KB.addListener){ if(KB && KB.addListener){
KB.addListener('keyboardWillShow', function(info){ var h=bzKbHeight(info&&info.keyboardHeight); r.style.setProperty('--kb', h+'px'); document.body.classList.add('kb-open'); var b=document.getElementById('msgs'); if(b) requestAnimationFrame(function(){ b.scrollTop=b.scrollHeight; }); }); KB.addListener('keyboardWillShow', function(info){ lastRaw=info&&info.keyboardHeight; rd(); setTimeout(function(){ var k=kbFromVV(); if(k>20){ applyKb(k); } else { var raw=lastRaw||0, dpr=window.devicePixelRatio||1; applyKb(raw>window.innerHeight?raw/dpr:raw); } rd(); }, 60); });
KB.addListener('keyboardWillHide', function(){ r.style.setProperty('--kb','0px'); document.body.classList.remove('kb-open'); }); KB.addListener('keyboardWillHide', function(){ lastRaw=0; applyKb(0); rd(); });
} }
rd();
}catch(_){} })(); }catch(_){} })();
</script> </script>
<div class="loading" id="loading"><div class="ld-inner"><img src="/loaders/loader-orbit-dark.svg" alt="" width="72" height="72"><div class="ld-wm">Biz <b>Connect</b></div><span class="ld-sub">Loading…</span></div></div> <div class="loading" id="loading"><div class="ld-inner"><img src="/loaders/loader-orbit-dark.svg" alt="" width="72" height="72"><div class="ld-wm">Biz <b>Connect</b></div><span class="ld-sub">Loading…</span></div></div>