Listbox: optionValue is ignored on some events #14167
Labels
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
Describe the bug
I don't know if this change is a regression or if its by designed now (as it works on previous PrimeNG versions), but the
onClick
event emits the entire object now, even if we provideoptionValue
.If this change has become the normal behavior, sorry for opening this issue.
Note -> This works for
onChange
event.If we have an array of objects, such as :
and if we provide
optionValue="code"
to p-listbox component, such as :<p-listbox .... optionLabel="name" optionValue="code" (onClick)="tralala($event.value)></p-listbox>
Then,
$event.value
will contains the entire object and not only the value of "code" property.Environment
MacOS / Angular / PrimeNG
Reproducer
https://stackblitz.com/edit/iztvzc?file=src%2Fapp%2Fdemo%2Flistbox-template-demo.html
Angular version
16.2.11
PrimeNG version
16.8.0
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
16.14.2
Browser(s)
No response
Steps to reproduce the behavior
1: Go to https://stackblitz.com/edit/iztvzc?file=src%2Fapp%2Fdemo%2Flistbox-template-demo.html
2: Open console
3: Click on one city
4: Check the console log (a string should be logged, not an object)
Expected behavior
Listbox "onClick"'s event should emits the value of the provided "optionValue" property and not the entire object.
The text was updated successfully, but these errors were encountered: