@@ -273,6 +273,16 @@ export default function CommentList(props: Props & StateProps & DispatchProps) {
273273 // eslint-disable-next-line react-hooks/exhaustive-deps -- Only on uri change
274274 } , [ uri ] ) ;
275275
276+ // Fetch linked/thread comment independently of pagination state
277+ useEffect ( ( ) => {
278+ if ( threadCommentId ) {
279+ fetchComment ( threadCommentId ) ;
280+ }
281+ if ( linkedCommentId ) {
282+ fetchComment ( linkedCommentId ) ;
283+ }
284+ } , [ fetchComment , linkedCommentId , threadCommentId ] ) ;
285+
276286 // Fetch top-level comments
277287 useEffect ( ( ) => {
278288 const isInitialFetch = currentFetchedPage === 0 ;
@@ -282,18 +292,9 @@ export default function CommentList(props: Props & StateProps & DispatchProps) {
282292 const hasRightFetchPage = Number ( isInitialFetch ) ^ Number ( isNewPage ) ;
283293
284294 if ( page !== 0 && hasRightFetchPage ) {
285- if ( page === 1 ) {
286- if ( threadCommentId ) {
287- fetchComment ( threadCommentId ) ;
288- }
289- if ( linkedCommentId ) {
290- fetchComment ( linkedCommentId ) ;
291- }
292- }
293-
294295 fetchTopLevelComments ( uri , undefined , page , COMMENT_PAGE_SIZE_TOP_LEVEL , sort , false ) ;
295296 }
296- } , [ currentFetchedPage , fetchComment , fetchTopLevelComments , linkedCommentId , page , sort , threadCommentId , uri ] ) ;
297+ } , [ currentFetchedPage , fetchTopLevelComments , page , sort , uri ] ) ;
297298
298299 React . useEffect ( ( ) => {
299300 if ( threadCommentId ) {
@@ -342,8 +343,7 @@ export default function CommentList(props: Props & StateProps & DispatchProps) {
342343 } else {
343344 delete window . pendingLinkedCommentScroll ;
344345 }
345- // eslint-disable-next-line react-hooks/exhaustive-deps
346- } , [ ] ) ;
346+ } , [ linkedCommentId , threadCommentId ] ) ;
347347
348348 // Infinite scroll
349349 useEffect ( ( ) => {
0 commit comments