Skip to content

Commit 8127759

Browse files
authored
fix: allow {accept} file selection w/o using the OS options
1 parent 86ea1df commit 8127759

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/utils/index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export function canUseFileSystemAccessAPI() {
197197
*/
198198
export function pickerOptionsFromAccept(accept) {
199199
if (isDefined(accept)) {
200-
return Object.entries(accept)
200+
const acceptForPicker = Object.entries(accept)
201201
.filter(([mimeType, ext]) => {
202202
let ok = true;
203203

@@ -217,11 +217,18 @@ export function pickerOptionsFromAccept(accept) {
217217

218218
return ok;
219219
})
220-
.map(([mimeType, ext]) => ({
221-
accept: {
220+
.reduce(
221+
(agg, [mimeType, ext]) => ({
222+
...agg,
222223
[mimeType]: ext,
223-
},
224-
}));
224+
}),
225+
{}
226+
);
227+
return [
228+
{
229+
accept: acceptForPicker,
230+
},
231+
];
225232
}
226233
return accept;
227234
}

src/utils/index.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,6 @@ describe("pickerOptionsFromAccept()", () => {
415415
{
416416
accept: {
417417
"image/*": [".png", ".jpg"],
418-
},
419-
},
420-
{
421-
accept: {
422418
"text/*": [".txt", ".pdf"],
423419
},
424420
},

0 commit comments

Comments
 (0)