fix select the same file bug (#538)

This commit is contained in:
A2ZH
2019-04-09 00:33:07 +08:00
committed by Jake Archibald
parent bffd9cb52a
commit 8f215a5b4b

View File

@@ -53,11 +53,17 @@ export default class Intro extends Component<Props, State> {
state: State = {};
private fileInput?: HTMLInputElement;
@bind
private resetFileInput() {
this.fileInput!.value = "";
}
@bind
private onFileChange(event: Event): void {
const fileInput = event.target as HTMLInputElement;
const file = fileInput.files && fileInput.files[0];
if (!file) return;
this.resetFileInput();
this.props.onFile(file);
}