-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
p-dropdown: optionLabel not displayed if optionValue is filled #14153
Comments
This issue is fixed with the 16.8.0, please check the changelog we've addressed this and similar issues. |
Thanks tested and solved, thanks @cetincakiroglu |
not fixed, breaking change if not able to specify optionValue then entire option will to be stored in ngModel (label and value) #14172 |
What do you mean ? If you optionValue is not specified, it will store/return the entire object. @pete-mcwilliams |
correct, and that is a breaking change, imagine in the future you need to update the label. Not only do you need to update the options list, you will need to update every row in the database because you are not longer accessing the options by a key. |
I think it's the intended way, and if I remember, it worked like that since a very long time, but I'm maybe wrong |
16.8.0 this should work allowing only the code to be persisted but does not as the template is only passed the optionValue. 16.4.2 working as it should same example as above with only primeng version change |
Hmm I think I don't understand where the problem is, sorry. I don't see any difference in the component behaviour. In both of the examples, you used optionValue, and when you print selectedCountry, selectedCountry will store the value in the field stored by the provided field name in optionValue. In the example "US" for example. |
Sorry, should not have linked your issue to mine, it was a different problem with same description, as you are not using a template (pTemplate="selectedItem") to display the label you do not have the problem. You can see in my 16.8.0 example the selected item is not displayed in the dropdown component. |
Describe the bug
I use in our app p-dropdown with optionValue and optionLabel inputs. Since the last primeng update I does not work anymore. The dropdown is empty, even if I change by hand the selected value.
I don't have this problem with primeng 16.4.2.
Environment
Reproducer
https://stackblitz.com/edit/w3qrm1?file=src%2Fapp%2Fdemo%2Fdropdown-reactive-forms-demo.html&file=src%2Fapp%2Fdemo%2Fdropdown-reactive-forms-demo.ts
Angular version
17.0.3
PrimeNG version
16.7.2
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
21.2.0
Browser(s)
Chrome 118.0.5993.117
Steps to reproduce the behavior
Use the reactive form example in the documentation here: https://primeng.org/dropdown#reactive-forms
Add optionValue.
Expected behavior
I would expect the label for the options entry be visible, since it's not the case.
The text was updated successfully, but these errors were encountered: