Skip to content

Commit 8711fa2

Browse files
committed
clear file input value after upload
1 parent 370d124 commit 8711fa2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/MediaLibrary/MediaLibrary.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,21 @@ class MediaLibrary extends React.Component {
112112
handlePersist = async event => {
113113
/**
114114
* Stop the browser from automatically handling the file input click, and
115-
* get the file for upload.
115+
* get the file for upload, and retain the synthetic event for access after
116+
* the asynchronous persist operation.
116117
*/
117118
event.stopPropagation();
118119
event.preventDefault();
120+
event.persist();
119121
const { persistMedia, privateUpload } = this.props;
120122
const { files: fileList } = event.dataTransfer || event.target;
121123
const files = [...fileList];
122124
const file = files[0];
123125

124126
await persistMedia(file, { privateUpload });
125127

128+
event.target.value = null;
129+
126130
this.scrollToTop();
127131
};
128132

0 commit comments

Comments
 (0)