From 66ec297eee28ecfda031577db75741b4a3002873 Mon Sep 17 00:00:00 2001 From: Zhou Yuhang <54398705+xquisite0@users.noreply.github.com> Date: Mon, 28 Jul 2025 10:44:39 +0800 Subject: [PATCH] [redditmon] inbox: automatically focus on first post in tabs (#1575) --- .../posts/InterceptedPostDetailClient.tsx | 11 ++++++++++ .../src/components/posts/PostsContext.tsx | 21 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/apps/redditmon/src/components/posts/InterceptedPostDetailClient.tsx b/apps/redditmon/src/components/posts/InterceptedPostDetailClient.tsx index b28e5cc8c..529f094c5 100644 --- a/apps/redditmon/src/components/posts/InterceptedPostDetailClient.tsx +++ b/apps/redditmon/src/components/posts/InterceptedPostDetailClient.tsx @@ -34,6 +34,8 @@ export default function InterceptedPostDetailClient({ handlePrevPost, markPostRelevancy, markPostReplyStatus, + posts, + selectedPostId, } = usePostsContext(); const toggleRelevant = () => { @@ -68,6 +70,15 @@ export default function InterceptedPostDetailClient({ }; }, [disableScope, enableScope]); + // Check if the current post is still valid in the context + const isPostValidInCurrentContext = + selectedPostId === post.id && posts.some((p) => p.id === post.id); + + // If the post is not valid in the current context, don't render the detail + if (!isPostValidInCurrentContext) { + return null; + } + return (