fix: gallery 'Media or File' sheet dismisses before you can pick media - #6093
Merged
Merged
Conversation
janicduplessis
marked this pull request as ready for review
July 9, 2026 15:27
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3470b40ded
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A gorhom modal dismissal fires both onChange(-1) and onDismiss. handleSheetChanges already handles onChange(-1), respecting the isProgrammaticChange flag and then resetting it. handleModalDismiss then ran with the flag already consumed, so it could no longer tell a programmatic dismissal from a user one and spuriously reported the close upward. For the gallery 'Media or File' -> 'Media Library' handoff, that spurious onOpenChange(false) reset the route back to 'gallery', canceling the nested-sheet transition. Native portals (react-native-teleport) made the sheet close slower, so the spurious close now lands after the 300ms handoff, breaking the flow that previously worked. handleModalDismiss is only a fallback for when gorhom skips onChange(-1) (dismiss mid-open-animation), so gate it on whether onChange(-1) already ran for this dismissal.
janicduplessis
force-pushed
the
janic/fix-gallery-nested-sheet-dismiss
branch
from
July 9, 2026 15:34
3470b40 to
7e8d5ef
Compare
dnbrwstr
approved these changes
Jul 9, 2026
6 tasks
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.
Fixes TLON-6142
Summary
Opening a gallery post (Pictures channel → New → "Media or File") flashes the second sheet ("Media Library / Capture / Upload a File / Voice Memo") open and immediately closes it, so you can't get to the media picker. The chat composer's single-level
+sheet is unaffected — this only bites the two-sheet handoff inAddGalleryPost.Changes
Root cause is in the shared
BottomSheetWrapper(native). A gorhom modal dismissal fires bothonChange(-1)andonDismiss.handleSheetChangeshandlesonChange(-1)— it respects theisProgrammaticChangeflag (skipping the callback for programmatic closes) and then resets the flag.handleModalDismissthen ran with the flag already consumed, so it could no longer tell a programmatic dismissal from a user one and reported the close upward a second time.For the gallery handoff, that spurious
onOpenChange(false)runs the parent'sonClose, which resetsrouteback to'gallery'— canceling thesetTimeout-driven transition to'add-attachment'.This is a latent bug that only recently detonated:
fix: bottom sheet modals fail to reopen after being dismissed), which addedhandleModalDismissas anonDismissfallback without theisProgrammaticChangeguard thathandleSheetChangesuses. Harmless at first — the spurious close landed before the 300ms handoff (gallery → gallery → add-attachment, a no-op).gallery → add-attachment → gallery), clobbering it. Confirmed by bisect: the flow works on a pre-feat(mobile): use native portals via react-native-teleport #6072 build and breaks once feat(mobile): use native portals via react-native-teleport #6072 is in.handleModalDismissis only a fallback for the case where gorhom skipsonChange(-1)(dismiss mid-open-animation), so it's now gated on whetheronChange(-1)already ran for this dismissal.How did I test?
iOS simulator, dev build, Pictures channel → New → Media or File:
Before/after screen recordings below.
Risks and impact
ActionSheet/ modal sheets)This touches the shared
BottomSheetWrapperused by every native modal sheet, so the blast radius is wide. The change only removes a redundant close signal — the real close is still driven byhandleSheetChanges(-1), unchanged — so it can't prevent a sheet from closing; worst case is the opposite (a sheet that gorhom dismisses without firingonChange(-1)fails to notify the parent), which the retained!reachedClosedIndexfallback path still handles. Worth a quick sanity pass on a couple of other sheets (channel actions, message long-press) during review.Rollback plan
Revert the PR — single-file change, no native/config/schema changes.
Screenshots / videos
Before
Screen.Recording.2026-07-09.at.11.17.59.AM.mov
After
Screen.Recording.2026-07-09.at.11.15.28.AM.mov