Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions components/dash-core-components/src/fragments/Upload.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,34 @@ export default class Upload extends Component {
// Handle drag-and-drop with folder support when multiple=true
if (event.dataTransfer && event.dataTransfer.items) {
const items = Array.from(event.dataTransfer.items);

// Get all entries synchronously before the first await
const entries = [];
const files = [];

for (const item of items) {
if (item.kind === 'file') {
const entry = item.webkitGetAsEntry
? item.webkitGetAsEntry()
: null;
if (entry) {
const entryFiles = await this.traverseFileTree(entry);
files.push(...entryFiles);
} else {
// Fallback for browsers without webkitGetAsEntry
const file = item.getAsFile();
if (file) {
files.push(file);
}
if (item.kind !== 'file') {
continue;
}

const entry = item.webkitGetAsEntry
? item.webkitGetAsEntry()
: null;
if (entry) {
entries.push(entry);
} else {
// Fallback for browsers without webkitGetAsEntry
const file = item.getAsFile();
if (file) {
files.push(file);
}
}
}
// Process all entries after collecting them
for (const entry of entries) {
const entryFiles = await this.traverseFileTree(entry);
files.push(...entryFiles);
}
return files;
}

Expand Down
Loading