diff --git a/.changeset/dry-points-fold.md b/.changeset/dry-points-fold.md new file mode 100644 index 00000000000..571bbc751e0 --- /dev/null +++ b/.changeset/dry-points-fold.md @@ -0,0 +1,5 @@ +--- +"@aws-amplify/ui-react-core": patch +--- + +chore: fix issue where drag and drop throws illegal invocation diff --git a/packages/react-core/src/utils/processDroppedItems.ts b/packages/react-core/src/utils/processDroppedItems.ts index 911e7dda47d..d42dca13632 100644 --- a/packages/react-core/src/utils/processDroppedItems.ts +++ b/packages/react-core/src/utils/processDroppedItems.ts @@ -48,13 +48,10 @@ export async function processDroppedItems( // Filter out and process files from the data transfer items await Promise.all( dataTransferItems - .reduce( - (acc, { kind, webkitGetAsEntry }) => - kind === 'file' && webkitGetAsEntry() - ? [...acc, webkitGetAsEntry()!] - : acc, - [] - ) + .reduce((acc, item) => { + const entry = item.webkitGetAsEntry(); + return item.kind === 'file' && entry ? [...acc, entry] : acc; + }, []) .map(processFileSystemEntry) );