primefaces / primeng

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

p-listbox: Can't select an item if the list of options is provided by a function #16083

Open CorporateDog opened 1 month ago

CorporateDog commented 1 month ago

Describe the bug

The listbox component doesn't allow you to select an item, if the list of options in the listbox is provided by a getter function.

Additionally (and this may be part of the issue) I've noticed that when hovering over items in the listbox, something is forcing change detection to fire on the component containing the listbox.

Environment

Windows 11, VSCode 1.91.1

Reproducer

https://stackblitz.com/edit/dfawkv-p1uc9r?file=src%2Fapp%2Flistbox-basic-demo.ts

Angular version

17.3.12

PrimeNG version

17.18.5

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.20.3

Browser(s)

Chrome 126.0.6478.182

Steps to reproduce the behavior

1.) Hover over the listbox items in the reproduction Stackblitz instance. You'll note that the 'Getting options for listbox' log message repeats. 2.) Attempt to click on one of the items. The listbox doesn't acknowledge a selection.

Expected behavior

The repeated change detection SHOULD NOT occur when simply hovering over a list box item.

Additionally, I should be able to trigger a selection with my mouse.

CorporateDog commented 1 month ago

This issue seems to be similar to the issue described with the selectButton component here:

https://github.com/primefaces/primeng/issues/14222