Skip to content

update bottom sheet backdrop close (DEV-2541) - #2437

Draft
tglaz wants to merge 4 commits into
mainfrom
DEV-2541/bottomsheet-backdrop-close-bug
Draft

tglaz wants to merge 4 commits into
mainfrom
DEV-2541/bottomsheet-backdrop-close-bug

Conversation

@tglaz

@tglaz tglaz commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

RN BottomSheets don’t close when clicking backdrop

DEV-2541

Summary by Sourcery

Ensure bottom sheet backdrop and external dismissals close controlled sheets reliably without duplicate callbacks or stale-sheet interference.

Bug Fixes:

  • Fix bottom sheet backdrop taps so they reliably close controlled sheets through the application dismissal flow.
  • Prevent stale or duplicate dismissal callbacks from notifying parents or affecting reopened sheets.

Enhancements:

  • Improve bottom sheet provider lifecycle handling, including single presentation per sheet, stack replacement behavior, and coordinated dismissal notifications.

Tests:

  • Add coverage for backdrop dismissal, provider lifecycle and stack behavior, controlled-sheet reopen races, and dismissal callback semantics.

@tglaz tglaz self-assigned this Sep 3, 2026
@sourcery-ai

sourcery-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The PR hardens controlled bottom-sheet backdrop closing against presentation/dismissal races by propagating provider-assigned sheet ids, isolating stale onClose callbacks, and making presentation and closing bookkeeping idempotent during rapid reopen and dismiss cycles.

Sequence diagram for race-safe controlled bottom-sheet dismissal

sequenceDiagram
    participant Controlled as BottomSheetModalControlled
    participant Provider as BottomSheetModalProvider
    participant Sheet as BottomSheetBase
    participant Parent as Parent

    Controlled->>Provider: showBottomSheet(render, options)
    Provider->>Sheet: present() once for id
    Sheet-->>Controlled: render(closeSheet, id)
    Controlled->>Controlled: activeSheetIdRef = id

    alt isOpen flips false during presentation
        Controlled->>Controlled: didQueueCloseRef = true
        Controlled->>Provider: closeSheet()
        Provider->>Sheet: dismiss() once for id
    else backdrop closes active sheet
        Sheet->>Provider: onDismiss(id)
        Provider->>Controlled: onClose(id)
        Controlled->>Parent: notify close
    end

    Sheet->>Provider: onDismiss(id)
    Provider->>Controlled: onClose(id)
    alt id is stale
        Controlled->>Controlled: ignore superseded dismissal
    else id is active
        Controlled->>Controlled: clear active refs
    end
Loading

File-Level Changes

Change Details Files
Track sheet identity and lifecycle state to prevent stale dismissals from affecting the currently active sheet.
  • Associate each rendered sheet with its provider-assigned id.
  • Ignore onClose callbacks from superseded sheets.
  • Reset and gate shared close refs across open, close, and mount-race transitions.
  • Queue at most one dismissal when a sheet mounts after the controlled state has already closed.
libs/expo/shared/ui-components/src/lib/BottomSheet/BottomSheetModalControlled.tsx
libs/expo/shared/ui-components/src/lib/BottomSheet/types.ts
Make provider presentation and dismissal bookkeeping idempotent for overlapping sheet lifecycles.
  • Pass sheet ids through render and onClose callbacks.
  • Present each sheet instance only once using a ref-backed id set.
  • Avoid redundant closing-state updates and clean up ids and refs on dismissal.
  • Initialize closing state lazily.
libs/expo/shared/ui-components/src/lib/BottomSheet/providers/BottomSheetModal/BottomSheetModalProvider.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@tglaz tglaz changed the title update bottom sheet backdrop close update bottom sheet backdrop close (DEV-2541) Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

🚀 Expo continuous deployment is ready for betterangels!

  • Project → betterangels
  • Environment → Preview
  • Platforms → android, ios
  • Scheme → betterangels
  🤖 Android 🍎 iOS
Runtime Version 4d84f3f87051ebb9c1713e7e2d4522e4b23135d9 4d84f3f87051ebb9c1713e7e2d4522e4b23135d9
Build Details Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview
Runtime version: 4d84f3f87051ebb9c1713e7e2d4522e4b23135d9
App version: 1.2.11
Git commit: a1900145e6c2315da5a85930acd4fcf2f8619aa2
Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview
Runtime version: 4d84f3f87051ebb9c1713e7e2d4522e4b23135d9
App version: 1.2.11
Git commit: a1900145e6c2315da5a85930acd4fcf2f8619aa2
Update Details Update Permalink
DetailsBranch: DEV-2541-bottomsheet-backdrop-close-bug
Runtime version: 4d84f3f87051ebb9c1713e7e2d4522e4b23135d9
Git commit: fe2862fcb9d70508461fc59629199e49d162a50e
Update Permalink
DetailsBranch: DEV-2541-bottomsheet-backdrop-close-bug
Runtime version: 4d84f3f87051ebb9c1713e7e2d4522e4b23135d9
Git commit: fe2862fcb9d70508461fc59629199e49d162a50e
Update QR

iOS Simulator Build: Simulator Build Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant