Multiselect: pTemplate="selectedItems" layout is empty on first render using Reactive forms #14424
Labels
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
Describe the bug
Without custom template:
Screen.Recording.2023-12-22.at.17.40.10.mov
With custom template:
Screen.Recording.2023-12-22.at.17.40.34.mov
When using reactive form and custom template:
<ng-template let-items pTemplate="selectedItems">
On first render, items are undefined, but this is not rerendered when default values in formControl are set
In my opinion if I look to https://github.com/primefaces/primeng/blob/master/src/app/components/multiselect/multiselect.ts
Constructor part sets selectedOption property, but it seems that it is undefined at first call but, probably right after first render value changes, but there is set onPush strategy, so template won't redraw as it should
How to fix? Didnt tried, but probably this is very similar to dropdown:
So something like this should fix the problem
`
`
Environment
This bug will be in any environment
Reproducer
No response
Angular version
17.0.5
PrimeNG version
17.2.0
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
18.0.6
Browser(s)
all
Steps to reproduce the behavior
No response
Expected behavior
No response
The text was updated successfully, but these errors were encountered: