fix(mobile): normalize keyboard height device-px -> points (was overshooting ~3x on 3x screens)

Root cause: the Keyboard plugin reports keyboardHeight in device pixels on this build; CSS needs points,
so the raw value overshot by the devicePixelRatio. Divide by DPR when the raw value exceeds the screen's
point height. Web-only.
Build marker -> 2026-07-18-batch102.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-18 01:13:57 +05:30
parent 233db2c140
commit 77a3ad455f
+10 -13
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-batch101';console.log('%cBiz Connect','color:#1F3B73;font-weight:bold','build '+window.__BUILD); <script>window.__BUILD='2026-07-18-batch102';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,18 +1127,15 @@ 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 to sit on the keyboard // Keyboard: with resize:none the WebView never resizes, so we raise the composer by the keyboard height.
// using the VisualViewport API — the ACTUAL amount the visible area shrinks by. This is measured, not the // The plugin reports that height in DEVICE PIXELS on some builds, but CSS wants points — so a raw value
// plugin's reported height (which overshot), so it lands exactly on the keyboard. // bigger than the screen's point height is divided by devicePixelRatio. This normalization makes it land
if(window.visualViewport){ // exactly on the keyboard regardless of unit.
var vv=window.visualViewport; function bzKbHeight(raw){ raw=raw||0; var dpr=window.devicePixelRatio||1; return Math.round(raw > window.innerHeight ? raw/dpr : raw); }
var onVV=function(){ var KB=C.Plugins&&C.Plugins.Keyboard;
var kb=Math.max(0, Math.round(window.innerHeight - vv.height - vv.offsetTop)); if(KB && KB.addListener){
r.style.setProperty('--kb', kb+'px'); 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; }); });
var open=kb>4; document.body.classList.toggle('kb-open', open); KB.addListener('keyboardWillHide', function(){ r.style.setProperty('--kb','0px'); document.body.classList.remove('kb-open'); });
if(open){ var b=document.getElementById('msgs'); if(b) b.scrollTop=b.scrollHeight; }
};
vv.addEventListener('resize', onVV); vv.addEventListener('scroll', onVV);
} }
}catch(_){} })(); }catch(_){} })();
</script> </script>