Skip to content

Commit dbe53ba

Browse files
fix(camera): Allow cancelation of sheet in Web, requires pwa-elements 3.4.0 or higher (#2284)
1 parent 8b8d7e5 commit dbe53ba

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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
@@ -719,7 +719,8 @@ private Uri getTempImage(Uri u, ByteArrayOutputStream bitmapOutputStream) {
719719
try {
720720
bis = new ByteArrayInputStream(bitmapOutputStream.toByteArray());
721721
newUri = saveImage(u, bis);
722-
} catch (IOException ex) {} finally {
722+
} catch (IOException ex) {
723+
} finally {
723724
if (bis != null) {
724725
try {
725726
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)