rf: dom queries in UserMessage component

This commit is contained in:
Carlos Daniel Vilaseca 2024-03-03 17:33:01 -05:00
parent a5c1ac9680
commit 13f0052122

View file

@ -20,18 +20,17 @@
let edit = false;
let editedContent = '';
let messageEditTextArea: HTMLTextAreaElement;
const editMessageHandler = async () => {
edit = true;
editedContent = message.content;
await tick();
const editElement = document.getElementById(`message-edit-${message.id}`);
editElement.style.height = '';
editElement.style.height = `${editElement.scrollHeight}px`;
messageEditTextArea.style.height = '';
messageEditTextArea.style.height = `${messageEditTextArea.scrollHeight}px`;
editElement?.focus();
messageEditTextArea?.focus();
};
const editMessageConfirmHandler = async () => {
@ -165,10 +164,11 @@
<div class=" w-full">
<textarea
id="message-edit-{message.id}"
bind:this={messageEditTextArea}
class=" bg-transparent outline-none w-full resize-none"
bind:value={editedContent}
on:input={(e) => {
e.target.style.height = `${e.target.scrollHeight}px`;
messageEditTextArea.style.height = `${messageEditTextArea.scrollHeight}px`;
}}
/>