Skip to content

🔥 [🐛] AttachmentPicker intercepts back events too eagerly #3633

@vanstinator

Description

@vanstinator

Issue

Describe your issue here

I recently upgraded a React Native app to Expo 56, and as part of that refactoring we switched from react-native-pager-view to PagerView from @expo/ui. This new component behaves differently than the prior component, and we quickly noticed that after the change our screens that contained a <Channel> on one of the pages required triggering back on Android twice before the screen would return to the previous screen.

After several hours of debugging we isolated the problem to AttachmentPicker. It contains a back handler that seemingly always intercepts the first back request, (at least when used on a PagerView, I'm not sure yet if that is related or not).

Steps to reproduce

Steps to reproduce the behavior:

  1. Checkout https://github.com/vanstinator/expo-ui-pagerview-back-bug
  2. From a machine configured to build and debug React Native on Android, EXPO_PUBLIC_STREAM_API_KEY=your_stream_key yarn android
  3. Tap the Open Pager button
  4. Initiate a back gesture
  5. Observe that the system does not pop your navigation stack and return you to the apps home screen

Expected behavior

When a <Channel> is included anywhere in the view hierarchy and the AttachmentPicker's bottom sheet is not open the back event should never be consumed by Stream's SDK but instead be allowed to propagate up the stack to the parent handler.

Project Related Information

Customization

Click To Expand

Nothing was customized, using purely out-of-the-box components

Offline support

  • I have enabled offline support.
    - [ ] The feature I'm having does not occur when offline support is disabled. (stripe out if not applicable)

Environment

Click To Expand

I've included a full working reproduction at https://github.com/vanstinator/expo-ui-pagerview-back-bug

package.json:

# N/A

react-native info output:

 OUTPUT GOES HERE
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • stream-chat-react-native version you're using that has this issue:
    • 9.3.0
  • Device/Emulator info:
    • I am using a physical device
    • OS version: Android 16 and Android 17
    • Device/Emulator: Pixel 10 Pro Fold

Additional context

The @expo/ui is fully built on top of Jetpack Compose and there have been other issues with event propagation such as expo/expo#46623 so I can't entirely rule out it being something weird there. But I left several breadcrumbs on the repro's README that seem to indicate an actual logic bug in AttachmentPicker https://github.com/vanstinator/expo-ui-pagerview-back-bug/blob/main/README.md

There's also this block that is suspect 😅 https://github.com/GetStream/stream-chat-react-native/blob/develop/package/src/components/AttachmentPicker/AttachmentPicker.tsx#L133-L137

Screenshots

screen-20260609-134848-1781027312907.mp4.2.mp4
Click To Expand


Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions