primefaces / primeng

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

Dropdown: Missing placeholder triggers unexpected ngModelChange #15340

Open stanislavKacmarik opened 2 weeks ago

stanislavKacmarik commented 2 weeks ago

Describe the bug

p-dropdown behaves non consistent - when attribute placeholder is present, then ngModelChange is not triggered during its initalization, but its triggered when placeholder is missing (or its value is empty string). Even when value bound for ngModel is changed automatically from code, p-dropdown without placeholder will trigger ngModelChange, but p-dropdown with placeholder is not triggering ngModelChange. In provided demo this change occurs after 5 seconds after component initialization.

Environment

17.14.1

Reproducer

https://stackblitz.com/edit/rsoiam-gmp8s3?file=src%2Fapp%2Fdemo%2Fdropdown-basic-demo.html

Angular version

17.3.1

PrimeNG version

17.14.1

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

v18.16.0

Browser(s)

Chrome 124

Steps to reproduce the behavior

Create 1 p-dropdown with placeholder and another without and compare differences when ngModelChange is triggered. After that, automatically update value, and see differences between dropdown with and without placeholder

Expected behavior

Absence of placeholder should not have any effects to ngModelChange, or at least this behavior should be documented