wix / wix/react-native-ui-lib

Press outside of ActionSheet crashs the application

Open
#2,714 2 comments 0 reactions 1 assignee View on GitHub

@nitzanyiz is already working on this.

Since Oct 17, 2023.

bug
Dominant language
TypeScript
Stars
7.2k
Forks
748
Avg merge
2d 18h
Merged PRs (30d)
1

Description

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
  • Components
  • Demo
  • Docs
  • Typings
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
  • React Native version: 0.68.6
  • React Native UI Lib version: 6.31.0
Affected platforms
  • Android
  • iOS
  • Web

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.