Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(camera): Allow cancelation of sheet in Web #2284

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

OS-pedrogustavobilro
Copy link
Contributor

The actionSheet prompt was previously not cancellable in Web, even though it is cancellable

  • on Android - setCancelable(false) not called, by default it is cancelable
  • and on iOS - UIAlertAction with style cancel allows sheet to be canceled when clicking outside.

This PR fixes that.

Addresses #2241 and ionic-team/pwa-elements#134

@jcesarmobile
Copy link
Member

The reason why it's not cancelable on web is because pwa-elements action sheet doesn't provide any event to indicate the cancelation, so allowing to cancel the action sheet will make the camera plugin call to hang as it won't reject nor resolve.

So for making the prompt cancelable, pwa-elements action sheet should be updated to emit an event on the cancellation and in camera plugin listen for that event to reject the call with an error as iOS and Android do.

@OS-pedrogustavobilro
Copy link
Contributor Author

OS-pedrogustavobilro commented Dec 17, 2024

@jcesarmobile -> opened a PR for pwa-elements to add an event listener for when the action sheet is dismissed - ionic-team/pwa-elements#138

Then, in this PR, will add the equivalent cancelation that's already present on native Android and iOS.

actionSheet.addEventListener('onCanceled', async () => {
    reject(new CapacitorException('User cancelled photos app'));
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants