ammarahm-ed / react-native-actions-sheet

A Cross Platform(Android, iOS & Web) ActionSheet with a flexible api, native performance and zero dependency code for react native. Create anything you want inside ActionSheet.
https://rnas.vercel.app
MIT License
1.41k stars 119 forks source link

Navigating to a modal screen from action sheet causes issues in iOS with React Native 0.73 #346

Open fikkatra opened 4 months ago

fikkatra commented 4 months ago

After upgrading to React Native 0.73, we experience issues when navigating from within an action sheet to a modal screen (using react-navigation), and hiding the action sheet when doing so. The issue only occurs in iOS and are probably related to iOS not allowing more than one (native) modal. It worked fine in RN v0.72.

This is the setup: the app has a page with an action sheet. From within the action sheet, it is possible to navigate to another screen, which is configured as a modal screen. On iOS, it slides out from the bottom. Before navigating to the modal screen, we close the action sheet using SheetManager.hide(), then execute the navigation.

This is the code that hides the action sheet and navigates to the modal screen:

  const navigateToModal = async () => {
    await SheetManager.hide(sheetId);
    navigation.navigate('Modal')
  }

What we observe:

The screencast below illustrates the behavior:

https://github.com/ammarahm-ed/react-native-actions-sheet/assets/8104336/031730af-d2d1-4d1f-9886-aa79593fe5f1

Some other observations:

I don't see any errors being logged. Since everything works fine if we omit SheetManager.hide, I'm assuming the problem is within this library.

Here is a simple code repo that reproduces the issue.

Currently using v0.9.2 of this library, but rolling back to v0.8 does not fix the issue.

LiamBrenner commented 2 months ago

@fikkatra I experienced a similar issue, but on React Native 0.71, and I managed to fix the issue by wrapping the navigation call in a setTimeout, in my case something like:

  const action = await SheetManager.show('my-sheet', {
    payload: {...},
  });

  if (action === 'EDIT') {
    setTimeout(() => {
      navigation.push('MyScreen', { ... });
    }, 100);
  } else if (action === 'DELETE') {
    ...
  }
chengfengfengwang commented 1 month ago

Maybe we need to wait until sheet close entirely then navigate to a new native modal ?