-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<select /> for number with *ngFor number #23
Comments
Use |
Indeed, those two values are different on purpose. The |
in this case and
|
But what is selected in the view? "User"? |
"Admin" :( |
Interesting. I think it's something wrong with the
it selects |
I'll try your example after work. |
I tried this locally by changing the simple form from the example app to use options$ = Observable.of([
{ 'id': 1, 'label': 'Admin' },
{ 'id': 3, 'label': 'Operator' },
{ 'id': 5, 'label': 'Foo' },
{ 'id': 2, 'label': 'User' },
]); <select [ngrxFormControlState]="formState.controls.favoriteColor">
<option [value]="null"></option>
<option *ngFor="let o of (options$ | async)" [value]="o.id">{{o.label}}</option>
</select> Can you please provide a reproduction repo? Or at least the full code for this, i.e. the full component and reducer? |
There is something funky going on and I'm not sure what. It seems all the Interestingly, if I swap to Here's the select:
The actions:
The reducer for
and the reducer for
the effects is basically just a HTTP request to an api like:
the component:
With
With
|
Also the relevant package versions
Edit: I've tried downgrading to Angular 5.0.5 / RXJS 5.5.2 and the last few versions of typescript (2.5.x/2.4.x) and that didn't make any difference |
Clutching at straws but I pulled out the form element to a seperate component so I could avoid the async pipe in bindings. Didn't work but interestingly again the With:
You end up with: So I'm not sure why NGRX-Forms is broken for me. |
I'll have another look later today but I have a social event so I can't guarantee I'll make it. You could help me in tracking down this issue by debugging locally though. You should be able to find the source of ngrx-forms while running the app in e.g. Chrome. The file should be named something like "forms.es5.js" (note that Angular forms has the same filename, so pick the right one). In there find the function My only theory right now is that somehow ngrx-forms and angular forms are interfering, but I don't know how that would be. |
Don't worry, I'm context switching to other tasks, this is an interesting problem... I set these break points: breakpoint 1: set is called with -1 then with 2 correctly breakpoint 2:called with -1 then with 2 correctly, however breakpoint 3: never hit |
Alright, it works like this: Each option registers itself with the parent select and gets assigned an ID. The select stores options in multiple mappings, one of which is value to ID. The In any case, at least I now know where to roughly search for the issue. |
I think I can help you replicate it. I had a hunch it was down the "delay" caused by the options coming from a HTTP based observable. If you do this:
it fails to select the option, but this passes because it's fast?
|
Debugging the I can see the |
You are right. Whenever a new option registers itself I need to check whether the selected option changed and if so update the state. I'll try to provide you with a fixed version to test it out. |
Cool. Thanks for your help. |
Alright, I think I have the fix. Can you please install the version from this link and see if it fixes your issue? Just extract the zip file into your project directory and then install it with
This should override the version from npm. |
👍 works correctly now! Many thanks, I'll await the 2.1.0 release :) |
It'll be 2.1.1 actually. I had to release 2.1.0 yesterday for another bugfix. I'll release the new version later today. |
I have just released version 2.1.1 which contains a fix for this issue. |
For anybody else running into this issue, I was still able to reproduce it with 6.x with code like this:
If you've paid attention, which I didn't and wasted enough hours on you'd notice that on the *ngFor i correctly binded to
|
Hey,
Can't seem to get this working.
Lets say you have the model:
and an array of
Bar
options:and you try to combine them in a form like:
I cannot get it to select the saved value.
Any ideas?
The text was updated successfully, but these errors were encountered: