react-native-action-sheet icon indicating copy to clipboard operation
react-native-action-sheet copied to clipboard

(ANDROID) Tapping out returns an `undefined` buttonIndex

Open esthor opened this issue 4 years ago • 0 comments

This seems to be android specific (can't repro on iOS).

When the action sheet dialog pops up on Android, if you tap outside of the dialog, it closes... BUT it also continues to execute and passes the buttonIndex of undefined. You can test by just console.log(buttonIndex) while on android and tapping outside the dialog. The workaround is not too difficult, but is a little tedious and people might easily miss it if not testing their implementations thoroughly on Android. This is more problematic if you are dynamically setting the available options and later trying to match them to call the appropriate function.

Workaround: Just include a catching conditional at the start of the buttonIndex function:

if (!buttonIndex && buttonIndex !== 0) {
    return;
}

esthor avatar Jun 30 '20 17:06 esthor