fix(webui): fit session search above the mobile keyboard

This commit is contained in:
Xubin Ren committed 2026-10-04 20:14:21 +08:00
1 parent fc729df9ab
commit 2442d88b91
6 files changed
+38 -21

No files matched your search

+6 -4
View File
@@ -9,15 +9,17 @@ export function useAppViewport() {
const viewport = window.visualViewport;
const root = document.getElementById("root");
if (!touch || !viewport || !root || isNativeRuntime()) return;
// Body portals (for example session search) share the app's viewport owner.
const viewportStyle = document.documentElement.style;
const update = () => {
// Pinch zoom pans the existing layout; it must not reflow it or chase the
// user's magnified viewport. Resume fitting when the scale returns to 1.
if (viewport.scale !== 1) return;
root.style.setProperty("--app-viewport-height", `${viewport.height}px`);
viewportStyle.setProperty("--app-viewport-height", `${viewport.height}px`);
// WebKit can report a negative offset after rotating a focused PWA.
// Do not move the navigation above the top edge with that overscroll.
root.style.setProperty("--app-viewport-top", `${Math.max(0, viewport.offsetTop)}px`);
viewportStyle.setProperty("--app-viewport-top", `${Math.max(0, viewport.offsetTop)}px`);
root.classList.add("visual-viewport");
// Only the keyboard's shortest layouts need a scrollable composer.
// Normal layouts must let the command and mention palettes overflow.
@@ -31,8 +33,8 @@ export function useAppViewport() {
viewport.removeEventListener("scroll", update);
root.classList.remove("visual-viewport");
root.classList.remove("short-visual-viewport");
root.style.removeProperty("--app-viewport-height");
root.style.removeProperty("--app-viewport-top");
viewportStyle.removeProperty("--app-viewport-height");
viewportStyle.removeProperty("--app-viewport-top");
};
}, [touch]);
}