Page MenuHomePhabricator

[native] fix Android cancel action sheet crash
ClosedPublic

Authored by ginsu on Apr 16 2023, 10:51 AM.
Tags
None
Referenced Files
F3368367: D7456.diff
Mon, Nov 25, 7:29 PM
Unknown Object (File)
Thu, Nov 21, 11:55 PM
Unknown Object (File)
Thu, Nov 21, 11:55 PM
Unknown Object (File)
Thu, Nov 21, 11:55 PM
Unknown Object (File)
Thu, Nov 21, 11:55 PM
Unknown Object (File)
Thu, Nov 21, 11:55 PM
Unknown Object (File)
Thu, Nov 21, 11:55 PM
Unknown Object (File)
Thu, Nov 21, 11:54 PM
Subscribers

Details

Summary

While testing the edit avatar flow for android, I encountered this bug where the app crashes when the user presses anywhere outside the actionsheet. The reason for this is that the value of selectedIndex when a user tries to cancel on android is -1, and the value of selectedIndex when a user tries to cancel on iOS is 0. This is due to action sheets on android generally not having a cancel option in the sheet but there being a cancel option with iOS

Test Plan

No longer triggering the crash, and we are getting the expected cancel behavior. Also double checked that iOS still behaves as expected

Before:

After:

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

native/tooltip/tooltip-context.react.js
121–122 ↗(On Diff #25200)

We can't use !selectedIndex because this will evaluate to true when selectedIndex is equal to zero

This revision is now accepted and ready to land.Apr 16 2023, 2:02 PM