@@ -51,6 +51,7 @@ const commentsLeft = ref(props.commentsCount);
5151const idToChildren = ref (new Map ());
5252const sortBy = ref (props .sortByInitialValue );
5353const hasOpenedComments = ref (false );
54+ const commentRefs = ref (new Map ());
5455
5556const createdNewCommentCallback = (newComment , userData ) => {
5657 console .log (" Created a new comment!" , newComment, userData);
@@ -59,9 +60,7 @@ const createdNewCommentCallback = (newComment, userData) => {
5960
6061 // Ensure DOM updates are complete, then scroll to the new comment
6162 nextTick (() => {
62- const newCommentElement = document .getElementById (
63- " comment_" + newComment .id
64- );
63+ const newCommentElement = commentRefs .value .get (` comment_${ newComment .id } ` );
6564 if (newCommentElement) {
6665 newCommentElement .scrollIntoView ({
6766 behavior: " smooth" ,
@@ -76,6 +75,7 @@ provide("commentableId", props.commentableId);
7675provide (" commentableKey" , props .commentableKey );
7776provide (" users" , readonly (usersMap));
7877provide (" createdNewCommentCallback" , createdNewCommentCallback);
78+ provide (" commentRefs" , commentRefs);
7979
8080const showEmptyState = computed (() => {
8181 return (
0 commit comments