@@ -308,7 +308,9 @@ export class DxcFileInputComponent
308308 if ( ! file . error ) {
309309 file . error = this . checkFileSize ( file . data ) ;
310310 }
311+ if ( ! file . error ) {
311312 this . fileAddService . add ( file ) ;
313+ }
312314 } ) ;
313315 }
314316 const inputs = Object . keys ( changes ) . reduce ( ( result , item ) => {
@@ -374,6 +376,27 @@ export class DxcFileInputComponent
374376 if ( this . callbackFile . observers ?. length > 0 && this . hasValue ) {
375377 if ( ! this . multiple ) {
376378 this . fileAddService . removeAll ( ) ;
379+
380+ let fileToAdd : FileData = {
381+ data : event ?. dataTransfer ?. files [ 0 ] ,
382+ image : null ,
383+ error : this . checkFileSize ( event ?. dataTransfer ?. files [ 0 ] ) ,
384+ eventType : this . fileEventType ,
385+ postResponse : this . postResp ,
386+ progress : {
387+ value : 0 ,
388+ status : "progress" ,
389+ } ,
390+ } ;
391+
392+ if ( fileToAdd . error ) {
393+ let fileData : FileData [ ] = [ ] ;
394+ fileData . push ( fileToAdd ) ;
395+ this . value = fileData ;
396+ this . callbackFile . emit ( fileData ) ;
397+ this . fileAddService . remove ( fileToAdd ) ;
398+ return fileData ;
399+ }
377400 }
378401
379402 if ( ( this . multiple == true && event ?. dataTransfer ?. files ?. length > 1 ) || ( this . multiple == false && event ?. dataTransfer ?. files ?. length == 1 ) ) {
@@ -391,6 +414,28 @@ export class DxcFileInputComponent
391414 if ( this . callbackFile . observers ?. length > 0 && this . hasValue ) {
392415 if ( ! this . multiple ) {
393416 this . fileAddService . removeAll ( ) ;
417+ let fileToAdd : FileData = {
418+ data : event ?. target ?. files [ 0 ] ,
419+ image : null ,
420+ error : this . checkFileSize ( event ?. target ?. files [ 0 ] ) ,
421+ eventType : this . fileEventType ,
422+ postResponse : this . postResp ,
423+ progress : {
424+ value : 0 ,
425+ status : "progress" ,
426+ } ,
427+ } ;
428+
429+ if ( fileToAdd . error ) {
430+ let fileData : FileData [ ] = [ ] ;
431+ fileData . push ( fileToAdd ) ;
432+ this . value = fileData ;
433+ this . callbackFile . emit ( fileData ) ;
434+ this . fileAddService . remove ( fileToAdd ) ;
435+ event . target . value = "" ;
436+ return fileData ;
437+ }
438+
394439 }
395440 this . onChangeRegister ( event . target . files ) ;
396441 this . getPreviewsFiles ( event . target . files ) ;
@@ -970,11 +1015,12 @@ export class DxcFileInputComponent
9701015 this . fileAddService . add ( file ) ;
9711016 } ) ;
9721017 }
973-
1018+
9741019 private isErrorShow = ( ) : boolean =>
9751020 this . value ?. length === 1 &&
9761021 this . mode === "file" &&
9771022 this . value [ 0 ] ?. error &&
9781023 ! this . multiple &&
9791024 ! this . disabled ;
9801025}
1026+
0 commit comments