From 5111954081dd9ec32f1c7a2cffeb275b56b996fe Mon Sep 17 00:00:00 2001 From: Tommaso Casaburi Date: Sat, 4 Jul 2026 23:13:49 +0700 Subject: [PATCH] fix: avoid pending post cleanup crash --- .../pending-post/__tests__/pending-post.test.tsx | 16 ++++++++++++++++ src/views/pending-post/pending-post.tsx | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/views/pending-post/__tests__/pending-post.test.tsx b/src/views/pending-post/__tests__/pending-post.test.tsx index f56070f6..e9d6d93b 100644 --- a/src/views/pending-post/__tests__/pending-post.test.tsx +++ b/src/views/pending-post/__tests__/pending-post.test.tsx @@ -133,6 +133,22 @@ describe('PendingPost', () => { expect(testState.navigateMock).not.toHaveBeenCalledWith('/not-found', { replace: true }); }); + it('does not register the scroll helper return value as an effect cleanup', async () => { + scrollToMock.mockReturnValueOnce({}); + testState.accountCommentIndex = '0'; + testState.accountComments = [{}]; + testState.post = { + communityAddress: 'music-posting.eth', + }; + + await renderPendingPost(); + + expect(() => { + act(() => root.unmount()); + }).not.toThrow(); + root = createRoot(container); + }); + it('passes normalized numeric-string pending indices to the account comment lookup', async () => { testState.accountCommentIndex = '01'; testState.accountComments = [{}, {}]; diff --git a/src/views/pending-post/pending-post.tsx b/src/views/pending-post/pending-post.tsx index 28b856af..836b720d 100644 --- a/src/views/pending-post/pending-post.tsx +++ b/src/views/pending-post/pending-post.tsx @@ -61,7 +61,9 @@ const PendingPost = () => { const isRetryingThisPendingPost = retryingAccountCommentIndex !== null && retryingAccountCommentIndex === normalizedAccountCommentIndex; const lastPendingBoardRef = useRef<{ accountCommentIndex: number; boardPath: string } | null>(null); - useEffect(() => window.scrollTo(0, 0), []); + useEffect(() => { + window.scrollTo(0, 0); + }, []); useEffect(() => { if (typeof normalizedAccountCommentIndex === 'number' && pendingBoardPath) {