Skip to content

Commit 06cf611

Browse files
fix(camera): Allow cancelation of sheet in Web, requires pwa-elements 3.4.0 or higher (#2284)
1 parent 16e66d5 commit 06cf611

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

camera/android/src/main/java/com/capacitorjs/plugins/camera/CameraPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,8 @@ private Uri getTempImage(Uri u, ByteArrayOutputStream bitmapOutputStream) {
707707
try {
708708
bis = new ByteArrayInputStream(bitmapOutputStream.toByteArray());
709709
newUri = saveImage(u, bis);
710-
} catch (IOException ex) {} finally {
710+
} catch (IOException ex) {
711+
} finally {
711712
if (bis != null) {
712713
try {
713714
bis.close();

camera/src/web.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class CameraWeb extends WebPlugin implements CameraPlugin {
2323
document.body.appendChild(actionSheet);
2424
}
2525
actionSheet.header = options.promptLabelHeader || 'Photo';
26-
actionSheet.cancelable = false;
26+
actionSheet.cancelable = true;
2727
actionSheet.options = [
2828
{ title: options.promptLabelPhoto || 'From Photos' },
2929
{ title: options.promptLabelPicture || 'Take Picture' },
@@ -36,6 +36,9 @@ export class CameraWeb extends WebPlugin implements CameraPlugin {
3636
this.cameraExperience(options, resolve, reject);
3737
}
3838
});
39+
actionSheet.addEventListener('onCanceled', async () => {
40+
reject(new CapacitorException('User cancelled photos app'));
41+
});
3942
} else {
4043
this.cameraExperience(options, resolve, reject);
4144
}

0 commit comments

Comments
 (0)