fix(web): stop the chat scroll bouncing on multiline input

The auto-resize reset the textarea to auto before measuring, which
collapsed it to one row for a frame. That resized the chat viewport,
the browser clamped its scroll to the old bottom, and the next input
scrolled back.

Measure the content in a hidden copy instead. The composer reports a
height change, and the room keeps the chat at the bottom only when the
reader is already there.

Typing and deleting lines now keeps the chat at the bottom without the
jump.
This commit is contained in:
vhaudiquet committed 2026-11-28 19:00:56 +01:00
1 parent f5087220da
commit ca333509a2
3 files changed
+78 -6

No files matched your search

+11 -2
View File
@@ -637,7 +637,7 @@ let stickScheduled = false
/// Keep the newest turn card or message in view while the log grows,
/// unless the reader has scrolled away from the bottom.
function scheduleStick() {
if (!stick.value || stickScheduled) return
if (!stick.value || suspendAutoScroll || stickScheduled) return
stickScheduled = true
void nextTick(() => {
stickScheduled = false
@@ -708,6 +708,10 @@ async function loadOlder() {
}
}
function onComposerResized() {
scheduleStick()
}
async function onSent(message: Message) {
addMessage(message, true)
stick.value = true
@@ -858,7 +862,12 @@ onBeforeUnmount(() => {
<p v-if="typingText" class="room-status-line">{{ typingText }}</p>
</div>
<ChatComposer :room-id="roomId" @sent="onSent" @typing="onTyping" />
<ChatComposer
:room-id="roomId"
@sent="onSent"
@typing="onTyping"
@resized="onComposerResized"
/>
</div>
<div