capacitor-plugins
capacitor-plugins copied to clipboard
feat: @capacitor/action-sheet - allow click-outside and back-button on ActionSheet on Android
Feature Request
Plugin
action-sheet
Description
Would be nice if tapping outside of the ActionSheet or using the hardware/software back button would close the ActionSheet.
Platform(s)
Android
Preferred Solution
Add the following to ActionSheetPlugin.java
Change
implementation.setCancelable(false);
to
implementation.setCancelable(true);
implementation.setOnCancelListener(() -> {
implementation.dismiss();
JSObject ret = new JSObject();
ret.put("index", -1);
call.resolve(ret);
});
Alternatives
None
Additional Context
None
I also discovered on iOS for iPad that you need to do this inside of ActionSheetPlugin.swift
var alertActions = [UIAlertAction]()
+ alertActions.append(UIAlertAction(title: "", style: .cancel, handler: {(_) -> Void in call.resolve(["index": -1])}))