fix(ui): the floating chat window follows the page when the browser pans to the focused input
This commit is contained in:
1 file changed
+5
-1
@@ -126,10 +126,13 @@ const winRect = computed<Rect>(() => {
|
||||
// this the bar sits under the keyboard.
|
||||
const keyboard = ref(0);
|
||||
const visibleHeight = ref(window.innerHeight);
|
||||
// How far the browser has panned the page up to show the focused input.
|
||||
const visibleTop = ref(0);
|
||||
function followViewport(): void {
|
||||
const vv = window.visualViewport;
|
||||
keyboard.value = keyboardCover(window.innerHeight, vv);
|
||||
visibleHeight.value = vv ? vv.height : window.innerHeight;
|
||||
visibleTop.value = vv ? Math.max(0, Math.round(vv.offsetTop)) : 0;
|
||||
}
|
||||
useEventListener(() => window.visualViewport, ["resize", "scroll"], followViewport);
|
||||
const phoneBottom = computed(() => phoneBarBottom(keyboard.value));
|
||||
@@ -144,7 +147,8 @@ const wrapStyle = computed<Record<string, string> | undefined>((): Record<string
|
||||
// A tablet's on-screen keyboard covers the layout viewport's bottom; keep
|
||||
// the window, and so its composer, in the part left above it.
|
||||
const fit = keyboard.value > 0 ? fitRect(rect, vw.value, visibleHeight.value) : rect;
|
||||
return { left: `${fit.x}px`, top: `${fit.y}px`, width: `${fit.w}px`, height: `${fit.h}px` };
|
||||
const top = keyboard.value > 0 ? fit.y + visibleTop.value : fit.y;
|
||||
return { left: `${fit.x}px`, top: `${top}px`, width: `${fit.w}px`, height: `${fit.h}px` };
|
||||
}
|
||||
const bar = barPlacement(rect, mode.value, vw.value);
|
||||
return { left: `${bar.x}px`, bottom: `${bar.bottom + keyboard.value}px`, width: `${bar.w}px` };
|
||||
|
||||
Reference in new issue
Block a user