fix(hub): keep mobile PWA AI navigation visible
Fix keyboard detection in standalone app so top nav and AI tabs stay visible; recognize PWA display mode for mobile layout.
This commit is contained in:
@@ -900,7 +900,10 @@
|
||||
}
|
||||
|
||||
function isMobileLayout() {
|
||||
return window.matchMedia("(max-width: 720px)").matches;
|
||||
if (window.matchMedia("(max-width: 720px)").matches) return true;
|
||||
if (window.matchMedia("(display-mode: standalone)").matches) return true;
|
||||
if (window.navigator && window.navigator.standalone === true) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function positionHasContracts(p) {
|
||||
@@ -1107,7 +1110,6 @@
|
||||
let syncHubAiMobileViewport = () => {};
|
||||
|
||||
function initHubAiMobileViewport() {
|
||||
const mq = window.matchMedia("(max-width: 720px)");
|
||||
const shell = document.querySelector(".app-shell");
|
||||
const chatInput = document.getElementById("ai-chat-input");
|
||||
if (!shell || !window.visualViewport) {
|
||||
@@ -1115,6 +1117,8 @@
|
||||
return;
|
||||
}
|
||||
|
||||
let baselineInnerH = Math.max(window.innerHeight, window.visualViewport.height || 0);
|
||||
|
||||
const scrollChatToEnd = () => {
|
||||
const box = document.getElementById("ai-chat-messages");
|
||||
if (box) requestAnimationFrame(() => { box.scrollTop = box.scrollHeight; });
|
||||
@@ -1122,7 +1126,7 @@
|
||||
|
||||
syncHubAiMobileViewport = () => {
|
||||
const onAi = document.body.classList.contains("hub-page-ai");
|
||||
if (!onAi || !mq.matches) {
|
||||
if (!onAi || !isMobileLayout()) {
|
||||
shell.style.removeProperty("height");
|
||||
shell.style.removeProperty("max-height");
|
||||
shell.style.removeProperty("width");
|
||||
@@ -1135,14 +1139,18 @@
|
||||
const h = Math.max(240, Math.round(vv.height));
|
||||
const top = Math.round(vv.offsetTop || 0);
|
||||
const left = Math.round(vv.offsetLeft || 0);
|
||||
const inputFocused = !!(chatInput && document.activeElement === chatInput);
|
||||
if (!inputFocused) {
|
||||
baselineInnerH = Math.max(baselineInnerH, window.innerHeight, h);
|
||||
}
|
||||
document.documentElement.style.setProperty("--hub-vvh", `${h}px`);
|
||||
shell.style.height = `${h}px`;
|
||||
shell.style.maxHeight = `${h}px`;
|
||||
shell.style.width = `${Math.round(vv.width)}px`;
|
||||
shell.style.transform =
|
||||
top > 0 || left > 0 ? `translate(${left}px, ${top}px)` : "";
|
||||
const keyboardLikely =
|
||||
top > 0 || h < window.innerHeight * 0.82 || document.activeElement === chatInput;
|
||||
const viewportShrunk = h < baselineInnerH * 0.72;
|
||||
const keyboardLikely = inputFocused && (viewportShrunk || top > 48);
|
||||
document.body.classList.toggle("hub-ai-keyboard-open", keyboardLikely);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user