p-dropdown can not set the options list default open
If you have a PrimeNG PRO Support subscription please post your issue at;
https://pro.primefaces.org
where our team will respond within 4 business hours.
If you do not have a PrimeNG PRO Support subscription, fill-in the report below. Please note that your issue will be added to the waiting list of community issues and will be reviewed on a first-come first-serve basis, as a result, the support team is unable to guarantee a specific schedule on when it will be reviewed. Thank you for your understanding.
Current Waiting Time: ~8 weeks.
I'm submitting a ... (check one with "x")
[ ] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Plunkr Case (Bug Reports) Please demonstrate your case at stackblitz by using the issue template below. Issues without a test case have much less possibility to be reviewd in detail and assisted.
https://stackblitz.com/github/primefaces/primeng-issue-template
Current behavior
Expected behavior
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
- Angular version: 5.X
- PrimeNG version: 5.X
- Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
-
Language: [all | TypeScript X.X | ES6/7 | ES5]
-
Node (for AoT issues):
node --version=
I'm submitting a bug report with solution: Here is demonstration: https://stackblitz.com/github/0shape/primeng-issue-template Current behavior: dropDown list DID NOT switch dropdown label on button click which updates ngModel Expected behavior: dropDown list should switch dropdown label on button click which updates ngModel
Solution is update method findOptionIndex at primeng/dropdown/dropdown.js:529 to compare not only object but single value itself.
if ((val == null && opts[i].value == null)
|| this.objectUtils.equals(val, opts[i].value, this.dataKey)
|| opts[i].value[this.dataKey] == val) {
index = i;
break;
}
Environment: Angular version: 6.1.9 PrimeNG version: 6.1.4 Browser: [Firefox 63.0.3]
Thanks @0shape, I used your could for a quick fix. I would also like to mention that the dropdown selected doesn't update on load. From my parent component I set an object and pass that object to the dropdown's ngModel. However, the dropdown doesn't selected that option.
I'm unable to replicate with the latest PrimeNG. If the issue still persists wit|h the new version please create a new issue with our stackblitz template.