Skip to content

Commit 99b5f4f

Browse files
committed
fix: specify image types for file input capture accept, fixes Firefox on Android
1 parent a6be112 commit 99b5f4f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

abstract/UploaderBlock.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ export class UploaderBlock extends ActivityBlock {
6363
});
6464
}
6565

66-
/** @param {boolean} capture */
67-
openSystemDialog(capture = false) {
66+
/** @param {{ captureCamera?: boolean }} options */
67+
openSystemDialog(options = {}) {
6868
let accept = mergeFileTypes([
6969
this.getCssData('--cfg-accept'),
7070
...(this.getCssData('--cfg-img-only') ? IMAGE_ACCEPT_LIST : []),
7171
]).join(',');
72+
7273
if (this.getCssData('--cfg-accept') && !!this.getCssData('--cfg-img-only')) {
7374
console.warn(
7475
'There could be a mistake.\n' +
@@ -79,9 +80,11 @@ export class UploaderBlock extends ActivityBlock {
7980
this.fileInput = document.createElement('input');
8081
this.fileInput.type = 'file';
8182
this.fileInput.multiple = !!this.getCssData('--cfg-multiple');
82-
this.fileInput.accept = accept;
83-
if (capture) {
83+
if (options.captureCamera) {
8484
this.fileInput.capture = '';
85+
this.fileInput.accept = IMAGE_ACCEPT_LIST.join(',');
86+
} else {
87+
this.fileInput.accept = accept;
8588
}
8689
this.fileInput.dispatchEvent(new MouseEvent('click'));
8790
this.fileInput.onchange = () => {

blocks/SourceBtn/SourceBtn.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class SourceBtn extends UploaderBlock {
3131
let el = document.createElement('input');
3232
var supportsCapture = el.capture !== undefined;
3333
if (supportsCapture) {
34-
this.openSystemDialog(true);
34+
this.openSystemDialog({ captureCamera: true });
3535
}
3636
return !supportsCapture;
3737
},

0 commit comments

Comments
 (0)