Add viewport-offset handling so mobile bottom bars stay anchored while virtual keyboards resize the visual viewport. - add a shared viewportOffset utility to compute keyboard-related visual viewport compensation - update dashboard app bootstrap/index logic to apply compensation variables for pinned footer/nav layout - extend mobile keyboard layout coverage with dedicated viewport compensation and bottom-bar tests - document the keyboard/pinned-bar behavior update in dashboard guide Files changed: docs/dashboard-guide.md | 2 +- .../mobile-bottom-bars-keyboard-layout.test.ts | 12 ++- .../viewport-compensation-keyboard.test.ts | 24 ++++++ packages/dashboard/app/index.html | 39 +++++++++- .../app/utils/__tests__/viewportOffset.test.ts | 86 ++++++++++++++++++++++ packages/dashboard/app/utils/viewportOffset.ts | 64 ++++++++++++++++ 6 files changed, 223 insertions(+), 4 deletions(-) Fusion-Task-Id: FN-5702 Fusion-Task-Lineage: be47ad0c-82df-4c38-9577-94c2eee49a0e
216 lines
11 KiB
HTML
216 lines
11 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<!-- Viewport configured for Capacitor mobile webview: disables pinch-zoom for app-like feel -->
|
|
<!-- interactive-widget=resizes-content: Android Chrome shrinks the layout
|
|
viewport when the soft keyboard opens, matching iOS behavior. Without
|
|
this, Chrome decouples layout viewport (innerHeight) from visual
|
|
viewport, leaving innerHeight stale and breaking keyboard-overlap math. -->
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover, interactive-widget=resizes-content" />
|
|
<script>
|
|
// Android Chrome (multi-window / split-screen / certain WebView modes)
|
|
// can leave the initial containing block (window.innerWidth/Height)
|
|
// stuck larger than the actual rendered canvas, while the DOM,
|
|
// visualViewport, and body all report the true dimensions. JS cannot
|
|
// force Chrome to recompute the ICB (neither setAttribute nor full
|
|
// element replacement of <meta viewport> works on those builds). So
|
|
// we publish the ICB→visible-viewport delta as CSS variables and
|
|
// `position: fixed` elements (nav bar, status bar) compensate via
|
|
// `bottom: var(--icb-bottom-offset)` etc. Healthy browsers see 0px.
|
|
(function () {
|
|
if (typeof window === 'undefined') return;
|
|
var baselineViewportHeight = null;
|
|
var NON_TEXT_INPUT_TYPES = {
|
|
checkbox: true,
|
|
radio: true,
|
|
button: true,
|
|
submit: true,
|
|
reset: true,
|
|
file: true,
|
|
range: true,
|
|
color: true,
|
|
hidden: true,
|
|
};
|
|
var isKeyboardFocusableElement = function (el) {
|
|
if (!el) return false;
|
|
if (el instanceof HTMLTextAreaElement) return true;
|
|
if (el instanceof HTMLInputElement) {
|
|
var type = (el.type || '').toLowerCase();
|
|
return !NON_TEXT_INPUT_TYPES[type];
|
|
}
|
|
return el instanceof HTMLElement && el.isContentEditable;
|
|
};
|
|
var apply = function () {
|
|
var vv = window.visualViewport;
|
|
var de = document.documentElement;
|
|
if (!de) return;
|
|
var innerW = window.innerWidth;
|
|
var innerH = window.innerHeight;
|
|
// Position relative to the visual viewport (what the user actually
|
|
// sees). This works correctly across states:
|
|
// - Healthy: vv == ICB, offsets are 0.
|
|
// - Chrome ICB-stuck-large bug: vv smaller than ICB → offset > 0
|
|
// pulls fixed elements up/left into the visible area.
|
|
// - Pinch-zoom in: vv smaller than ICB → ditto.
|
|
// - Pinch-zoom out: vv larger than ICB → offsets clamp at 0.
|
|
var vvW = vv ? Math.round(vv.width) : innerW;
|
|
var vvH = vv ? Math.round(vv.height) : innerH;
|
|
var vvOffTop = vv ? vv.offsetTop : 0;
|
|
var vvOffLeft = vv ? vv.offsetLeft : 0;
|
|
var vvScale = vv ? vv.scale : 1;
|
|
var rightOffset = Math.max(0, innerW - vvOffLeft - vvW);
|
|
var rawBottomOffset = Math.max(0, innerH - vvOffTop - vvH);
|
|
var activeElementIsKeyboardFocusable = isKeyboardFocusableElement(document.activeElement);
|
|
if (!activeElementIsKeyboardFocusable) {
|
|
baselineViewportHeight = baselineViewportHeight === null ? vvH : Math.max(baselineViewportHeight, vvH);
|
|
}
|
|
|
|
// Keep in sync with packages/dashboard/app/utils/viewportOffset.ts.
|
|
// Ignore keyboard-driven visualViewport shrink (iOS) so fixed mobile
|
|
// bars stay pinned to page bottom and are covered by keyboard.
|
|
var bottomOffset = rawBottomOffset;
|
|
if (activeElementIsKeyboardFocusable && vvScale <= 1.01 && baselineViewportHeight !== null) {
|
|
var keyboardShrink = Math.max(0, baselineViewportHeight - vvH);
|
|
if (keyboardShrink > 0) {
|
|
bottomOffset = Math.max(0, rawBottomOffset - keyboardShrink);
|
|
}
|
|
}
|
|
de.style.setProperty('--icb-right-offset', rightOffset + 'px');
|
|
de.style.setProperty('--icb-bottom-offset', bottomOffset + 'px');
|
|
};
|
|
window.addEventListener('orientationchange', apply);
|
|
window.addEventListener('resize', apply);
|
|
if (window.visualViewport) {
|
|
window.visualViewport.addEventListener('resize', apply);
|
|
window.visualViewport.addEventListener('scroll', apply);
|
|
}
|
|
apply();
|
|
// Tail: ICB can drift after task content renders.
|
|
setTimeout(apply, 100);
|
|
setTimeout(apply, 500);
|
|
setTimeout(apply, 1500);
|
|
setTimeout(apply, 3000);
|
|
})();
|
|
</script>
|
|
<script>
|
|
// Append ?vpdebug to the URL to show a fixed overlay with live viewport
|
|
// + media-query state. Diagnostic only.
|
|
(function () {
|
|
if (!/[?&]vpdebug\b/.test(location.search)) return;
|
|
var box = document.createElement('div');
|
|
box.style.cssText =
|
|
'position:fixed;top:0;right:0;z-index:2147483647;background:#000;color:#0f0;font:11px/1.3 monospace;padding:6px 8px;border:1px solid #0f0;white-space:pre;pointer-events:none;max-width:70vw;';
|
|
var update = function () {
|
|
if (document.body && box.parentNode !== document.body) document.body.appendChild(box);
|
|
var vv = window.visualViewport;
|
|
var nav = document.querySelector('.mobile-nav-bar');
|
|
var navInfo = 'null';
|
|
if (nav) {
|
|
var r = nav.getBoundingClientRect();
|
|
var cs = window.getComputedStyle(nav);
|
|
navInfo = Math.round(r.width) + 'x' + Math.round(r.height) + ' disp=' + cs.display + ' vis=' + cs.visibility;
|
|
}
|
|
var mqMobile768 = window.matchMedia('(max-width: 768px)').matches;
|
|
var mqMobileH = window.matchMedia('(max-height: 480px)').matches;
|
|
var mqMobileCombo = window.matchMedia('(max-width: 768px), (max-height: 480px)').matches;
|
|
var mqTablet = window.matchMedia('(min-width: 769px) and (max-width: 1024px)').matches;
|
|
box.textContent =
|
|
'win ' + window.innerWidth + 'x' + window.innerHeight + '\n' +
|
|
'vv ' + (vv ? Math.round(vv.width) + 'x' + Math.round(vv.height) + ' s' + vv.scale.toFixed(2) : 'n/a') + '\n' +
|
|
'dpr ' + window.devicePixelRatio + '\n' +
|
|
'html ' + document.documentElement.clientWidth + 'x' + document.documentElement.clientHeight + '\n' +
|
|
'body ' + (document.body ? document.body.clientWidth + 'x' + document.body.clientHeight : 'n/a') + '\n' +
|
|
'mq w<=768 ' + mqMobile768 + '\n' +
|
|
'mq h<=480 ' + mqMobileH + '\n' +
|
|
'mq combo ' + mqMobileCombo + '\n' +
|
|
'mq tablet ' + mqTablet + '\n' +
|
|
'nav ' + navInfo + '\n' +
|
|
'orient ' + (screen.orientation ? screen.orientation.type : 'n/a');
|
|
};
|
|
var attach = function () {
|
|
if (!document.body) { requestAnimationFrame(attach); return; }
|
|
document.body.appendChild(box);
|
|
update();
|
|
setInterval(update, 500);
|
|
window.addEventListener('resize', update);
|
|
window.addEventListener('orientationchange', update);
|
|
if (window.visualViewport) window.visualViewport.addEventListener('resize', update);
|
|
};
|
|
attach();
|
|
})();
|
|
</script>
|
|
<title>Fusion</title>
|
|
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
|
|
<link rel="manifest" href="/manifest.json" />
|
|
<link
|
|
rel="preload"
|
|
href="/fonts/SymbolsNerdFontMono-Regular.ttf"
|
|
as="font"
|
|
type="font/ttf"
|
|
crossorigin
|
|
/>
|
|
<meta name="theme-color" content="#1a1a2e" />
|
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
<link rel="apple-touch-icon" href="/icons/icon-192.png" />
|
|
<script>
|
|
// Theme initialization - runs before React to prevent flash
|
|
(function() {
|
|
try {
|
|
var mode = localStorage.getItem('kb-dashboard-theme-mode') || 'dark';
|
|
var colorTheme = localStorage.getItem('kb-dashboard-color-theme') || 'default';
|
|
var validThemes = ['default', 'ocean', 'forest', 'sunset', 'zen', 'berry', 'high-contrast', 'industrial', 'monochrome', 'slate', 'ash', 'graphite', 'silver', 'solarized', 'factory', 'ayu', 'one-dark', 'nord', 'dracula', 'gruvbox', 'tokyo-night', 'catppuccin-mocha', 'github-dark', 'everforest', 'rose-pine', 'kanagawa', 'night-owl', 'palenight', 'monokai-pro', 'slime', 'brutalist', 'neon-city', 'parchment', 'terminal', 'glass', 'horizon', 'vitesse', 'outrun', 'snazzy', 'porple', 'espresso', 'mars', 'poimandres', 'ember', 'rust', 'copper', 'foundry', 'carbon', 'sandstone', 'lagoon', 'frost', 'lavender', 'neon-bloom', 'sepia'];
|
|
if (!validThemes.includes(colorTheme)) {
|
|
colorTheme = 'default';
|
|
}
|
|
var fontScale = Number(localStorage.getItem('kb-dashboard-font-scale-pct') || '100');
|
|
if (!Number.isFinite(fontScale)) {
|
|
fontScale = 100;
|
|
}
|
|
fontScale = Math.min(125, Math.max(85, Math.round(fontScale)));
|
|
var systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
var effectiveMode = mode === 'system' ? (systemDark ? 'dark' : 'light') : mode;
|
|
document.documentElement.setAttribute('data-theme', effectiveMode);
|
|
document.documentElement.setAttribute('data-color-theme', colorTheme);
|
|
document.documentElement.style.fontSize = fontScale + '%';
|
|
if (colorTheme !== 'default') {
|
|
var base = document.baseURI || (document.location && document.location.href) || '';
|
|
var themeDataUrl;
|
|
if (!base) {
|
|
themeDataUrl = '/theme-data.css';
|
|
} else if (base.indexOf('http://') === 0 || base.indexOf('https://') === 0) {
|
|
themeDataUrl = new URL('/theme-data.css', base).toString();
|
|
} else if (base.indexOf('file://') === 0) {
|
|
if (base.endsWith('/')) {
|
|
themeDataUrl = base.slice(0, -1) + '/theme-data.css';
|
|
} else {
|
|
var lastSlashIndex = base.lastIndexOf('/');
|
|
themeDataUrl = lastSlashIndex >= 0
|
|
? base.slice(0, lastSlashIndex) + '/theme-data.css'
|
|
: '/theme-data.css';
|
|
}
|
|
} else {
|
|
themeDataUrl = '/theme-data.css';
|
|
}
|
|
var existingLink = document.getElementById('theme-data');
|
|
if (existingLink && existingLink.tagName === 'LINK' && existingLink.href !== themeDataUrl) {
|
|
existingLink.href = themeDataUrl;
|
|
}
|
|
}
|
|
} catch (e) {
|
|
document.documentElement.setAttribute('data-theme', 'dark');
|
|
document.documentElement.setAttribute('data-color-theme', 'default');
|
|
document.documentElement.style.fontSize = '100%';
|
|
}
|
|
})();
|
|
</script>
|
|
<script type="module" src="./main.tsx"></script>
|
|
<!-- fusion:view-preload -->
|
|
<link rel="stylesheet" href="/theme-data.css" id="theme-data" />
|
|
</head>
|
|
<body>
|
|
<div id="root"></div>
|
|
</body>
|
|
</html>
|