Open monsterrave opened 2 months ago
The setup of adding an option in your example directive modifies the options array by unshifting a new item onto it. This may not trigger an angular update. If you instead provide a new array it works as expected.
this.dropdown.options = [
{
label: 'root ' + this.dropdown.options.length,
items: [
{ label: 'child ' + this.dropdown.options.length, value: 'None' },
],
},
...this.dropdown.options,
];
Describe the bug
When the user opens the dropdown list, I want to add an dropdown item.
This is no problem in an ungrouped dropdown, but when I set
[group]="true"
this does not seem to work any longer...Environment
Reproducer
https://stackblitz.com/edit/btpn8a-fttwuo?file=src%2Fapp%2Fapp.module.ts,src%2Fapp%2Faddoption.directive.ts,src%2Fapp%2Fdemo%2Fdropdown-demo.ts,src%2Findex.html,src%2Fapp%2Fdemo%2Fdropdown-demo.html,src%2Fkarma.conf.js,package.json
Angular version
17.3.6
PrimeNG version
17.3.3
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
18.20.3
Browser(s)
No response
Steps to reproduce the behavior
click to open ungrouped dropdown -> should add dropdown option to list
set dropdown
[group]="true"
click to open grouped dropdown -> no option added
Expected behavior
should have same behaviour both in grouped and ungrouped dropdowns