diff --git a/ui/src/chat/ChatDock.vue b/ui/src/chat/ChatDock.vue index 2b5cb86f0..80c62b236 100644 --- a/ui/src/chat/ChatDock.vue +++ b/ui/src/chat/ChatDock.vue @@ -126,10 +126,13 @@ const winRect = computed(() => { // 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 | undefined>((): Record 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` };