fix(mobile): fix 100%-reproducible comments drawer crash#14516
Merged
Conversation
…ivity Profile pages use a collapsible tab view (horizontal pager + vertical scroll). The global native-stack option `fullScreenGestureEnabled: true` makes the swipe-to-pop recognizer span the entire screen, so a slightly diagonal vertical scroll gets hijacked as a back gesture and the list fails to scroll. The feed is unaffected because it is a root tab screen with no back-swipe competing for the gesture. Set `fullScreenGestureEnabled: false` on the Profile screen so swipe-back is edge-only, letting mid-screen scrolling reach the list. Mirrors the existing treatment on the Chat screen. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gorhom/portal renders portal content at a PortalHost that is a sibling
of {children} in BottomSheetModalProvider's inner PortalProvider tree —
NOT a descendant. This means CommentDrawerContext.Provider (which lives
inside {children}) is absent from the ancestor chain when the BottomSheet
content renders.
CommentBlockInternal was calling useCommentDrawer() to obtain
closeAndExitNowPlaying. Because CommentDrawerContext is unreachable from
the portal render location, useCommentDrawer() threw
"useCommentDrawer must be used within a CommentDrawerProvider" every time
any comment rendered, which the ErrorBoundary caught and surfaced as the
"Something went wrong" toast.
Fix: thread closeAndExitNowPlaying through CommentSectionContext (which IS
provided inside the portal content by CommentSectionProvider) rather than
reading it directly from CommentDrawerContext in CommentBlockInternal.
- packages/common: add optional closeAndExitNowPlaying prop to
CommentSectionProviderProps and expose it in CommentSectionContext
- CommentDrawer: call useCommentDrawer() at the CommentDrawer level
(which IS inside CommentDrawerContext.Provider) and forward the
callback into CommentSectionProvider
- CommentBlock: remove useCommentDrawer() call; read closeAndExitNowPlaying
from useCurrentCommentSection() with optional chaining
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause:
CommentBlockInternalcalleduseCommentDrawer()to readcloseAndExitNowPlaying, but@gorhom/bottom-sheetrendersBottomSheetModalcontent via@gorhom/portalat aPortalHostthat is a sibling ofCommentDrawerContext.Providerin the React tree — not a descendant. SouseCommentDrawer()receivedundefinedcontext and threw every time any comment rendered. TheErrorBoundarycaught it and showed the "Something went wrong" toast.Fix: thread
closeAndExitNowPlayingthroughCommentSectionContext(which is provided inside the portal content) instead.CommentDrawersits insideCommentDrawerContext.Providerand safely reads the callback there, then passes it down viaCommentSectionProvider.Changes
packages/common/src/context/comments/commentsContext.tsx— add optionalcloseAndExitNowPlayingtoCommentSectionProviderProps; expose in context valuepackages/mobile/src/components/comments/CommentDrawer.tsx— calluseCommentDrawer()at drawer level; forwardcloseAndExitNowPlayingintoCommentSectionProviderpackages/mobile/src/components/comments/CommentBlock.tsx— removeuseCommentDrawer()call; read fromuseCurrentCommentSection()with optional chainingTest plan