-
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
Component: Dropdown #14367
Comments
after #14241, this is the 2nd major issue for the dropdown component. I would warn anyone from upgrading to 17, IMHO it didnt have enough time to bake. @Draganlazarev90 note that your stackblitz is still on angular 16 and primeng 16.9.1
|
Since 16.6.0 PrimeNG has constantly broken our builds, and we are now reluctant to even update anything. I would advise implementing more tests for the components so they do not break on every other pull request. |
@Draganlazarev90, try surrounding the content of the template with an <ng-template let-item pTemplate="selectedItem">
<ng-containger *ngIf="item"> {{ item.label }} </ng-container>
</ng-template> The actual bug is that the template is used even if there is no element selected. |
I've seen multiple bugfixes for Adding an optional chaining operator prevents the error, but this was not required before. <ng-template let-item pTemplate="selectedItem">{{ item?.label }}</ng-template> |
In my case, until version 15.4.1, when I pass the items to the p-dropdown, the first item is selected by default, which is not the case since v16. Having that error is just a side-effect of not having a default value in my opinion. Does someone knows something about that missing default value ? |
This issue is really two bugs :
After examining the changes in pull request #14643, it appears that only the first bug of this issue is fixed by pull request #14643. The "very simple demo" reproducer provided in the pull request only addresses the first part of this issue The second bug of this issue is related to issue #14596. The pull request #14665 fixes issue #14596 and also fixes the second bug of this issue. The first video listed below is running this issues original reproducer(https://stackblitz.com/edit/stackblitz-starters-5fabhi) and "only" demonstrates the second bug of the issues. DropdownFilterWithTemplateBug.movThe second video listed below is with the changes from pull request #14665 and shows bug 2 of this issue has been fixed DropdownFilterWithTemplateFix.mov |
…-fix Fix #14367: Dropdown selected item template
Describe the bug
Having
<ng-template let-item pTemplate="selectedItem">{{ item.label }}</ng-template>
throws Cannot read properties of undefined (reading 'label') error if no item is selected initially, while if you have [filter]="true" and you have a selected an item, then start typing in the filter input the selected item is not displayed
Environment
https://stackblitz.com/edit/stackblitz-starters-5fabhi
Reproducer
No response
Angular version
17.0.5
PrimeNG version
17.1
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
20.10
Browser(s)
No response
Steps to reproduce the behavior
Expected behavior
No response
The text was updated successfully, but these errors were encountered: