Claude: Improve robustness of chat scrolling

This commit is contained in:
Alessandro Pignotti 2024-12-20 11:50:04 +01:00
parent 7a3531be01
commit 109063e433

View File

@ -1,5 +1,6 @@
<script>
import { apiState, setApiKey, addMessage, messageList, currentMessage } from '$lib/anthropic.js'
import { tick } from 'svelte';
import PanelButton from './PanelButton.svelte';
export let handleTool;
function handleKeyEnter(e)
@ -30,13 +31,18 @@
var textArea = e.target;
textArea.style.height = textArea.scrollHeight + "px";
}
async function scrollToBottom(node)
{
await tick();
node.scrollTop = node.scrollHeight;
}
function scrollMessage(node, messageList)
{
// Make sure the messages are always scrolled to the bottom
node.scrollTop = node.scrollHeight;
scrollToBottom(node);
return {
update(messageList) {
node.scrollTop = node.scrollHeight;
scrollToBottom(node);
}
}
}