primefaces / primeng

The Most Complete Angular UI Component Library
https://primeng.org
Other
10.29k stars 4.56k forks source link

p-multiselect: chips and selectedItems bug #15953

Open Emiliorth opened 3 months ago

Emiliorth commented 3 months ago

Describe the bug

When you use display="chips", after selecting some items and then changing array of options to different in comparision to selected items, labels inside chips disappear. When you use pTemplate and let-selectedItems, those becomes empty array. It should carry some values copy, instead of some options based ones (I'm guessing)

Environment

Angular, PrimeNG

Reproducer

No response

Angular version

18.0.3

PrimeNG version

17.18.2

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

22.2.0

Browser(s)

Chrome

Steps to reproduce the behavior

No response

Expected behavior

No response

mehmetcetin01140 commented 3 months ago

Hi,

Could you please share a stackblitz example so we can identify the issue clearly?

Emiliorth commented 3 months ago

Hello,

I am little unable to do that. I can post code here. This is an example for selectedItems to be different than form control value, when you have some options, select few of them and then change options array value to different array (like when you get paged data from BE when you type something in filter)

<p-multiSelect [formControlName]="controlName"
                               [inputId]="inputId"
                               appendTo="body"
                               optionLabel="label"
                               optionValue="value"
                               [options]="options"
                               [filter]="filterable"
                               (onFilter)="setGetMultiselectOptionsTrigger($event)">

                         <ng-template pTemplate="selectedItems" let-selectedItems>
                                   <p-tag styleClass="rad-text-body-support"
                                   [value]="entry.label"
                                   *ngFor="let entry of selectedItems"></p-tag>
                        </ng-template>

                </p-multiSelect>

When it comes to chips, you just remove custom template and use PrimeNG chips display