Page MenuHomePhabricator

[native] fix Android cancel action sheet crash
ClosedPublic

Authored by ginsu on Apr 16 2023, 10:51 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 6, 4:31 AM
Unknown Object (File)
Fri, May 3, 10:33 PM
Unknown Object (File)
Apr 4 2024, 10:58 PM
Unknown Object (File)
Apr 4 2024, 10:58 PM
Unknown Object (File)
Apr 4 2024, 10:58 PM
Unknown Object (File)
Apr 4 2024, 10:58 PM
Unknown Object (File)
Apr 4 2024, 10:58 PM
Unknown Object (File)
Apr 4 2024, 10:58 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