diff --git a/src/lib/components/CommentsSheet.svelte b/src/lib/components/CommentsSheet.svelte index 66957d2..8c7d5d6 100644 --- a/src/lib/components/CommentsSheet.svelte +++ b/src/lib/components/CommentsSheet.svelte @@ -168,13 +168,18 @@ ?.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); }); } else { - comments = [{ ...newComment, replyCount: 0, replies: [] }, ...comments]; + // Server sorts top-level by hearts desc, then createdAt asc. A + // brand-new comment has 0 hearts and the newest timestamp, so it + // belongs at the very bottom — append instead of prepending. + comments = [...comments, { ...newComment, replyCount: 0, replies: [] }]; justPostedId = newComment.id; safeTimeout(() => { justPostedId = null; }, 300); requestAnimationFrame(() => { - document.querySelector('.comments-list')?.scrollTo({ top: 0, behavior: 'smooth' }); + document + .querySelector(`[data-comment-id="${newComment.id}"]`) + ?.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); }); } commentInput?.clear();