-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Dropdown value not set properly when options come later than value #11526
Comments
I also think something broke with 13.4.0. We had to wrap alot of |
I would like to add to this. Thanks, |
We are also experiencing this issue, I suspect it is related to #8806. we have had to issue change detection between setting options and setting the value if being done in ngOnInit. |
We have the same issue |
@cetincakiroglu I think you also need to check if current value is not null before updating model:
Otherwise empty formcontrol becomes dirty and obtain red border if current value of dropbox is null and options are changed. |
Hi @cetincakiroglu , I am working on v15.4.1 for can't set 'value' and 'options' in the same time. Please refer to the initial commits below: I have a normal scenario that just need to change the obj and objList as below But after this change it seems I have to put obj before the objList, somehow there item is from backend I can't get it earlier. So I have to set it: obj = null; to avoid the exceptions. Finally the code become like: this.http.post(..).subscribe(resp=>{ setTimeout(()=>{ |
I think I got my problem is because I put the 'placeholder' that blocked the default value, I removed and issue solved. ^_^ |
I'm submitting a ... (check one with "x")
https://stackblitz.com/edit/primeng-dropdown-demo-tefc6o?file=src/app/app.component.ts
Current behavior
When the options are set after the value is set then it sets the value to null. This is because when the value is set the dropdown tries to find the option that belongs to this value, but if the options are not available yet, then it will set the value to null.
By time the options are loaded (async) the value is null, and thus wont be able to find the actual value.
Expected behavior
It is expected that the value should not be set to null, but should keep it's value.
Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/primeng-dropdown-demo-tefc6o?file=src/app/app.component.ts
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
Language: [all | TypeScript X.X | ES6/7 | ES5]
Node (for AoT issues):
node --version
=The text was updated successfully, but these errors were encountered: