SelectControlValueAccessor overwriting NativeElement's value if using custom control value accessor #25578
Labels
area: forms
freq2: medium
P4
A relatively minor issue that is not relevant to core functions
state: confirmed
state: needs more investigation
type: bug/fix
Milestone
I'm submitting a...
Current behavior
I'm using custom control value accessor UseValueAsNumber with ReactiveForms on SELECT element but default SelectControlValueAccessor from Angular is overwriting values set by UseValueAsNumber.
The problem seems to be following:
this.renderer.setProperty( this.elementRef.nativeElement, 'value', this.value );
NgSelectOption.setValue()
method is fired which internally callsif (this._select) this._select.writeValue(this._select.value);
. Howeverthis._select.value
isundefined
(as there is only 1 ControlValueAccessor allowed per FormControl) butthis._select
(which is in fact SelectControlValueAccessor instance) overwrites NativeElement's value toundefined
and in HTML the correct value is never selected.Expected behavior
Do not overwrite NativeElement's value property in order to display correct value in HTML.
Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/angular-gitter-marugk
What is the motivation / use case for changing the behavior?
Environment
The text was updated successfully, but these errors were encountered: