File uploader: broken reactive forms implementation not calling CVA onChangeCallback
Detailed description
Due to an invalid check in file uploader's value setter, ControlValueAccessor's onChange callback is never invoked.
This prevents users of the file uploader component to leverage all of the features of Angular reactive forms since the FormControl's valueChanges observable never emits.
When a file is added, the internal value is pointing to the same object due to this assignment
https://github.com/IBM/carbon-components-angular/blob/e497cda8912cfa64dbffdd4a3032a22dde01186d/src/file-uploader/file-uploader.component.ts#L224
When the value setter is executed, the condition within always evaluates to false since both v and this.files reference the same object (because of the above assignment on line 224, v is this.files).
https://github.com/IBM/carbon-components-angular/blob/e497cda8912cfa64dbffdd4a3032a22dde01186d/src/file-uploader/file-uploader.component.ts#L181-L184
Is this a feature request (new component, new icon), a bug, or a general issue?
Bug
Is this issue related to a specific component?
File uploader
What did you expect to happen? What happened instead? What would you like to see changed?
ControlValueAccessor's change callback should be invoked, which is expected since this component is supposed to fully support reactive forms. That means that the form control's valueChanges observable would actually emit the internal value of the file uploader component, as it should.
What offering/product do you work on? Any pressing ship or release dates we should be aware of?
IBM EKMF Web
Steps to reproduce the issue
https://codesandbox.io/s/carbon-components-angular-forked-file-uploader-cva-reactive-control-not-so-reactive-er748x?file=/src/app/app.component.ts
- Click Add files button
- Add any random files
- Observe
valueChangescounter and/or console log. - Nothing is emitted from control's
valueChanges