You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File list in $event object is getting cleared from memory while still in use
onFileSelected event of the ng2FileSelect directive when the "multiple" attribute is used.
Steps to reproduce:
Create html input element of type "File" and using ng2FileSelect directive along with "multiple" attribute and create handler like (onFileSelected)="selected($event)"
Run application, click input box, select one or more files
In the event handler, log the value of the $event argument to the console
Desired behavior:
FileList object shows (details collapsed) in console.
Expand FileList object in console, individual Files should show in console, length property should reflect number of files
Observed behavior:
FileList object shows (details collapsed) in console.
Expand FileList object in console, no Files exist in the FileList object. Length property is 0.
Why is this happening?: On this line the html input "value" property is being cleared before the async .emit() event has finished what it needs to do which is causing the files in the FileList to get cleared from memory before the event handler code has finished using it.
Possible fix idea:
Make deep copy of "files" variable in the onChange() event and emit that instead.
The text was updated successfully, but these errors were encountered:
I also found this to be a problem. Because the input's value gets reset when 'multiple' is applied, the files emitted are getting lost and it also destroys validation for the input in my case.
File list in $event object is getting cleared from memory while still in use
onFileSelected event of the ng2FileSelect directive when the "multiple" attribute is used.
Steps to reproduce:
Desired behavior:
FileList object shows (details collapsed) in console.
Expand FileList object in console, individual Files should show in console, length property should reflect number of files
Observed behavior:
FileList object shows (details collapsed) in console.
Expand FileList object in console, no Files exist in the FileList object. Length property is 0.
Why is this happening?:
On this line the html input "value" property is being cleared before the async .emit() event has finished what it needs to do which is causing the files in the FileList to get cleared from memory before the event handler code has finished using it.
Possible fix idea:
Make deep copy of "files" variable in the onChange() event and emit that instead.
The text was updated successfully, but these errors were encountered: