Press outside of ActionSheet crashs the application

Aperta
#2,714 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@nitzanyiz ci sta già lavorando.

Dal 17/10/2023.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug

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
Lingua principale
TypeScript
Stelle
7.2k
Fork
749
Merge medio
29m
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wix/react-native-ui-lib

Tutte le issue di wix/react-native-ui-lib

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.