Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,15 @@

// Track current input value - initialized by effect when existingComment changes
let currentValue = $state('');
let textareaEl: HTMLTextAreaElement | null = null;

// Update value when existingComment changes (for editing mode)
// Update value when existingComment changes (for editing mode). Reset scroll
// on identity change so a previously-scrolled textarea doesn't leak its
// offset into the next comment being viewed.
$effect(() => {
existingComment?.id;
currentValue = existingComment?.content ?? '';
if (textareaEl) textareaEl.scrollTop = 0;
});

function handleInput(e: Event) {
Expand Down Expand Up @@ -107,6 +112,7 @@
style="top: {top}px; left: {left}px; width: {width}px;"
>
<textarea
bind:this={textareaEl}
class="comment-textarea"
{placeholder}
value={currentValue}
Expand Down