Open rubenteck opened 4 months ago
PrimeNG's Dropdown allows the developer to define both a label and value. The problem you are experiencing is because you are not fully utilizing this capability. I have updated your original reproducer and with the changes the dropdown works as expected as long as you use the new getValue method to access the selected. PrimeNG, without any changes to the Dropdown component, can handle your use case.
updated reproducer: https://stackblitz.com/edit/github-bjxtkz-ueanuf?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.module.ts
The video below demonstrates your use case working properly with the current PrimeNG dropdown
https://github.com/primefaces/primeng/assets/45439491/1e4fa756-44e5-4b46-94e4-065a57d26ad1
Thank you for your solution. While it's possible to create an empty value like this, I don't think it solves the problem of the empty value not showing the placeholder when selected. If I'm wrong about this, please explain it further :)
Thank you for your solution. While it's possible to create an empty value like this, I don't think it solves the problem of the empty value not showing the placeholder when selected. If I'm wrong about this, please explain it further :)
I don't think I can explain further.
Obviously, it's up to PrimeNG to determine whether or not this issue #15308 is valid.
Hi,
We're currently updating the tests. Once the dropdown is updated, we'll test this issue and your PR to avoid breaking changes. I'm moving this to the next milestone.
Describe the bug
When adding null as a selectable option, the placeholder isn't shown on load, when selecting the null value (the 'empty' option) or when clearing the dropdown. In my example, the values are objects of type { label: 'label', value: 'value' } with the optionLabel and optionValue params set on the p-dropdown component. The null value is set as { label: null, value: null }.
Environment
I use a windows 11 laptop with IntelliJ. Angular 17.3.4, PrimeNG 17.13.0 and node v18.20.1.
Reproducer
https://stackblitz.com/edit/github-bjxtkz?file=src%2Fapp%2Fapp.component.html
Angular version
17.3.4
PrimeNG version
17.13.0
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
v18.20.1
Browser(s)
No response
Steps to reproduce the behavior
Expected behavior
the dropdowns value should be the placeholder when loaded, cleared or empty is selected.