Fix ActionSheet completion callback not called when dialog is dismissed #26902
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
#26429 introduced this problem: when the action sheet is dismissed without having selected and then canceled an action, neither of the success or failure callbacks is called. This causes the Promise that opens the action sheet in the Javascript code to remain unfulfilled. This fix checks that if no activity was chosen, in other words the dismiss button on the share dialog was pressed and the dialog was closed, then the success callback will still be called.
Changelog
[iOS] [Fixed] - Fix ActionSheet completion callback not called when dialog is dismissed
Test Plan
I'm using the react-native-share component to invoke the action sheet. Add these lines to the Javascript code:
import Share from 'react-native-share';
Share.open({
url: 'http://www.facebook.com'
}).finally(() => {
console.log('finally called');
});
In the ActionSheet dialog, press the dismiss button without having selected an action. Without this fix, the finally function is not called. With the fix, it is called. All other behavior is the same as before.