From 654d02a67999beb3c7ea5efe9d092f42a71cdd44 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 28 Jul 2025 10:40:08 -0500 Subject: [PATCH] Fix parent read more occurring further up the tree --- src/state/queries/usePostThread/traversal.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/state/queries/usePostThread/traversal.ts b/src/state/queries/usePostThread/traversal.ts index 7d8cd64640..2809d32e98 100644 --- a/src/state/queries/usePostThread/traversal.ts +++ b/src/state/queries/usePostThread/traversal.ts @@ -372,16 +372,21 @@ export function sortAndAnnotateThreadItems( /* * Tree-view only. * - * If there's an upcoming parent read more, this branch is part of the - * last branch of the sub-tree, and the item itself is the last child, - * insert the parent "read more". + * If there's an upcoming parent read more, this branch is part of a + * branch of the sub-tree that is deeper than the + * `upcomingParentReadMore`, and the item following the current item + * is either undefined or less-or-equal-to the depth of the + * `upcomingParentReadMore`, then we know it's time to drop in the + * parent read more. */ if ( view === 'tree' && metadata.upcomingParentReadMore && - metadata.isPartOfLastBranchFromDepth === + metadata.isPartOfLastBranchFromDepth && + metadata.isPartOfLastBranchFromDepth >= metadata.upcomingParentReadMore.depth && - metadata.isLastChild + (metadata.nextItemDepth === undefined || + metadata.nextItemDepth <= metadata.upcomingParentReadMore.depth) ) { subset.splice( i + 1,