Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listbox: optionValue is ignored on some events #14167

Closed
Adrii77 opened this issue Nov 21, 2023 · 0 comments
Closed

Listbox: optionValue is ignored on some events #14167

Adrii77 opened this issue Nov 21, 2023 · 0 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@Adrii77
Copy link

Adrii77 commented Nov 21, 2023

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 provide optionValue.

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 :

cities = [
{ name: 'New York', code: 'NY' },
{ name: 'Rome', code: 'RM' },
...
]

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.

@Adrii77 Adrii77 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 21, 2023
@Adrii77 Adrii77 changed the title Listbox: optionValue is ignored Listbox: optionValue is ignored on some events Nov 21, 2023
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 22, 2023
@cetincakiroglu cetincakiroglu self-assigned this Nov 22, 2023
@cetincakiroglu cetincakiroglu added this to the 16.9.0 milestone Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

2 participants