-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.handleInputChange()
- use .currentTarget
; clear the input using ''
#5381
base: main
Are you sure you want to change the base?
Conversation
Diff output filesdiff --git a/packages/@uppy/dashboard/lib/Dashboard.js b/packages/@uppy/dashboard/lib/Dashboard.js
index a4e8014..d666201 100644
--- a/packages/@uppy/dashboard/lib/Dashboard.js
+++ b/packages/@uppy/dashboard/lib/Dashboard.js
@@ -494,7 +494,7 @@ export default class Dashboard extends UIPlugin {
};
this.handleInputChange = event => {
event.preventDefault();
- const files = toArray(event.target.files);
+ const files = toArray(event.currentTarget.files || []);
if (files.length > 0) {
this.uppy.log("[Dashboard] Files selected through input");
this.addFiles(files);
diff --git a/packages/@uppy/dashboard/lib/components/AddFiles.js b/packages/@uppy/dashboard/lib/components/AddFiles.js
index 8a0edf9..8e4ee54 100644
--- a/packages/@uppy/dashboard/lib/components/AddFiles.js
+++ b/packages/@uppy/dashboard/lib/components/AddFiles.js
@@ -16,7 +16,7 @@ class AddFiles extends Component {
};
this.onFileInputChange = event => {
this.props.handleInputChange(event);
- event.target.value = null;
+ event.currentTarget.value = "";
};
this.renderHiddenInput = (isFolder, refCallback) => {
var _this$props$allowedFi;
diff --git a/packages/@uppy/drag-drop/lib/DragDrop.js b/packages/@uppy/drag-drop/lib/DragDrop.js
index 5f2d2c3..2515b3b 100644
--- a/packages/@uppy/drag-drop/lib/DragDrop.js
+++ b/packages/@uppy/drag-drop/lib/DragDrop.js
@@ -36,12 +36,12 @@ export default class DragDrop extends UIPlugin {
}
};
this.onInputChange = event => {
- const files = toArray(event.target.files);
+ const files = toArray(event.currentTarget.files || []);
if (files.length > 0) {
this.uppy.log("[DragDrop] Files selected through input");
this.addFiles(files);
}
- event.target.value = null;
+ event.currentTarget.value = "";
};
this.handleDragOver = event => {
var _this$opts$onDragOver, _this$opts;
diff --git a/packages/@uppy/file-input/lib/FileInput.js b/packages/@uppy/file-input/lib/FileInput.js
index 13cfa50..e859b0c 100644
--- a/packages/@uppy/file-input/lib/FileInput.js
+++ b/packages/@uppy/file-input/lib/FileInput.js
@@ -40,9 +40,9 @@ export default class FileInput extends UIPlugin {
}
handleInputChange(event) {
this.uppy.log("[FileInput] Something selected through input...");
- const files = toArray(event.target.files);
+ const files = toArray(event.currentTarget.files || []);
this.addFiles(files);
- event.target.value = null;
+ event.currentTarget.value = "";
}
handleClick() {
this.input.click(); |
536bfc9
to
2ee1645
Compare
''
instead of null
.handleInputChange()
- use .currentTarget
; clear the input using ''
event.preventDefault() | ||
const files = toArray((event.target as HTMLInputElement).files!) | ||
const files = toArray(event.currentTarget.files || []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const files = toArray(event.currentTarget.files || []) | |
const files = toArray(event.currentTarget.files ?? []) |
private onInputChange = (event: ChangeEvent) => { | ||
const files = toArray((event.target as HTMLInputElement).files!) | ||
private onInputChange = (event: TargetedEvent<HTMLInputElement, Event>) => { | ||
const files = toArray(event.currentTarget.files || []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const files = toArray(event.currentTarget.files || []) | |
const files = toArray(event.currentTarget.files ?? []) |
this.uppy.log('[FileInput] Something selected through input...') | ||
const files = toArray((event.target as HTMLFileInputElement).files) | ||
const files = toArray(event.currentTarget.files || []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const files = toArray(event.currentTarget.files || []) | |
const files = toArray(event.currentTarget.files ?? []) |
I assume you checked that using |
This PR:
event.target.value = ''
is preventing, added that demo to the commentsChangeEvent
toTargetedEvent<HTMLInputElement, Event>
target
=>currentTarget
,null
=>''
) is a consequence of the correct typingNew version is tested in:
Testing consists of:
onBeforeFileAdded
currentTarget.files
actually has files