Skip to content

Commit

Permalink
fix: work around Chromium File System Access API bug
Browse files Browse the repository at this point in the history
This works around https://crbug.com/1264708 by always including a
description in the FilePickerAcceptType passed to the options of
window.showOpenFilePicker().

Fixes #1127.
Fixes #1222.
Fixes #1190.
  • Loading branch information
dlech authored and okonet committed Oct 12, 2022
1 parent 8127759 commit c36ab5b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,7 @@ describe("useDropzone() hook", () => {
multiple: true,
types: [
{
description: "Files",
accept: { "application/pdf": [] },
},
],
Expand Down
2 changes: 2 additions & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ export function pickerOptionsFromAccept(accept) {
);
return [
{
// description is required due to https://crbug.com/1264708
description: "Files",
accept: acceptForPicker,
},
];
Expand Down
1 change: 1 addition & 0 deletions src/utils/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ describe("pickerOptionsFromAccept()", () => {
})
).toEqual([
{
description: "Files",
accept: {
"image/*": [".png", ".jpg"],
"text/*": [".txt", ".pdf"],
Expand Down

0 comments on commit c36ab5b

Please sign in to comment.