Skip to content

Cannot distinguish between event handlers when doing drag-n-drop #79

Closed
@alexandis

Description

@alexandis

Hi,
I am back :)
I've used the following markup to cover both drag-n-drop and usual selection for multiple file upload:

<ngx-mat-dropzone (drop)="onDropDocuments($event)">
    <input type="file" fileInput [ngModel]="files" [ngModelOptions]="{ standalone: true }" [multiple]="true"(ngModelChange)="onSelectDocuments($event)" />
</ngx-mat-dropzone>

Unfortunately, it works well only for an ordinary select, because only onSelectDocuments is triggered. When I use drag-n-drop, both onSelectDocuments and onDropDocuments handlers are triggered and as a result, I get the issue, because the code has to process the same logic twice. How to avoid this and clearly divide the handlers?

I used some custom logic, that's why I use onDropDocuments handler. And also I found using ngModel in my case instead of formControl to be preferrable.

In fact, the main reason for having the custom code was to get the initial source path of the file by all means, since we needed to pass this info to server. If I could obtain this information in other way, probably I would get rid of the issue as well by eliminating some custom handlers...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions