bezenson / react-native-unicorn-modals

Custom modals with Imperative API 🦄
https://inferusvv.github.io/react-native-unicorn-modals/
MIT License
34 stars 2 forks source link

Menu item `onPress` handlers not invoked #5

Closed rechtar closed 1 year ago

rechtar commented 1 year ago

Hi there! First of all, bravo for the library 😁 Definitely the best of the kind I've found so far both in terms of appearance and API design.

There's a small bug in v0.5.0: in the code to open a menu:

modal.show(
  'menu',
  {
    items: [
      { text: 'Default variant', onPress: () => {} },
      { text: 'Cancel variant', variant: 'cancel', onPress: () => {} },
      { text: 'Destructive variant', variant: 'destructive', onPress: () => {} },
    ],
  },
);

None of these onPress callbacks get called. I looked into the source code and was able to fix it by changing a line in Menu.tsx:

<MenuItem key={item.text} onPress={createActionCallback()} theme={theme} variant={item.variant}>

to

<MenuItem key={item.text} onPress={createActionCallback(item.onPress)} theme={theme} variant={item.variant}>

Just posting it here so you guys can fix it upstream. Thanks for the work! 👍

bezenson commented 1 year ago

Hi! I am happy to hear that :)

Thank you! Issue is fixed. Please update to 0.5.1

https://github.com/inferusvv/react-native-unicorn-modals/pull/6