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.42k stars 119 forks source link

Problem with show() immediately after await hide() #280

Closed anlinguist closed 5 months ago

anlinguist commented 1 year ago

I have this onPress handler for a Text component (of which there are hundreds):

onPress={async () => {
  if (SheetManager.get("word-sheet")) {
    await SheetManager.hide("word-sheet")
  }
  SheetManager.show("word-sheet", {
    payload: { word: indword, language: bookData[docToSee as keyof typeof bookData].language },
  });
}}

The registered WordSheet allows backgroundInteractionEnabled. I want the user to be able to click on a word to see the action sheet and then click on a new word, have the previous word action sheet hide and then show the new word action sheet.

This doesn't seem to be working.

  1. On subsequent clicks, the height of the WordSheet is very small, I can't even see the content of the action sheet.
  2. If I dismiss the WordSheet via gestureEnabled, I can no longer click on new words.

I have also tried using hideAll(), but it didn't work at all.

My last resort was to add a timer to SheetManager.show, to run 10ms after await SheetManager.hide returns:

onPress={async () => {
  if (SheetManager.get("word-sheet") && SheetManager.get("word-sheet").current?.isOpen()) {
    await SheetManager.hide("word-sheet")
  }
  // wait 1ms for the sheet to hide
  setTimeout(() => {
    SheetManager.show("word-sheet", {
      payload: { word: indword, language: bookData[docToSee as keyof typeof bookData].language },
    });
  }, 10);
}}

This seems to be working! I played around a bit with the timing, 1 ms is too little and there was some cases where the WordSheet wouldn't show, or would render incorrectly, and I found the 10ms consistently worked.

ammarahm-ed commented 1 year ago

Hi, is this happening on iOS?

Veeksi commented 9 months ago

Hi, is this happening on iOS?

I have this same issue and yes it is happening only on iOS