wix / react-native-ui-lib

UI Components Library for React Native
https://wix.github.io/react-native-ui-lib/
MIT License
6.59k stars 717 forks source link

Press outside of ActionSheet crashs the application #2714

Open edersonmberti opened 1 year ago

edersonmberti commented 1 year ago

Description

Used the ActionSheet component, when the component is visible and the user press anywhere outside the component the application crashes.

Somehow when this happens the option index sent to the onOptionPress function is always the same as the size of the options array.

options.length = 3, the value sent is 3.

Related to

Steps to reproduce

  1. Use the ActionSheet component
  2. Show the ActionSheet
  3. Press outside of the ActionSheet component
  4. See the error

Expected behavior

Hide the ActionSheet.

Actual behavior

Crash the application.

More Info

Code snippet

Current code:

  onOptionPress(optionIndex: number) {
    this.props.options?.[optionIndex].onPress?.();
    this.props.onDismiss?.();
  }

Fix:

  onOptionPress(optionIndex: number) {
    this.props.options?.[optionIndex]?.onPress?.();
    this.props.onDismiss?.();
  }

Screenshots/Video

Error: simulator_screenshot_02996209-69E9-4AC4-A31F-8A41DB30C732

Environment

Affected platforms

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

nitzanyiz commented 1 year ago

I couldn't reproduce the error. Could you elaborate on when and how you get this error?