Skip to content
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

fix issue with upload of the same file #391

Merged
merged 5 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
(mouseleave)="isDragoverFile = false"
(drop)="tryUploadFile($event)">
<input
#fileInput
(change)="tryUploadFile($event)"
type="file"
[accept]="extensionsString"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { CommonModule } from '@angular/common';
import {
Component,
ElementRef,
EventEmitter,
Input,
OnChanges,
OnInit,
Output,
SimpleChanges
SimpleChanges,
ViewChild
} from '@angular/core';
import { catchError, Observable, of, take } from 'rxjs';
import { convertSize } from '../../utils/internal/size-utils';
Expand Down Expand Up @@ -77,6 +79,8 @@ export class CpsFileUploadComponent implements OnInit, OnChanges {
*/
@Output() uploadedFileRemoved = new EventEmitter<string>();

@ViewChild('fileInput') fileInput!: ElementRef<HTMLInputElement>;
lukasmatta marked this conversation as resolved.
Show resolved Hide resolved

isDragoverFile = false;
uploadedFile?: File;
extensionsString = '';
Expand Down Expand Up @@ -150,6 +154,10 @@ export class CpsFileUploadComponent implements OnInit, OnChanges {
const name = this.uploadedFile?.name ?? '';
this.uploadedFile = undefined;
this.uploadedFileRemoved.emit(name);

if (this.fileInput) {
this.fileInput.nativeElement.value = '';
}
}

private _isFileExtensionValid(file?: File) {
Expand Down
Loading