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: onClick and onDblClick Even Emitters not working properly #14161

Closed
siddhareddy opened this issue Nov 21, 2023 · 2 comments
Closed

Listbox: onClick and onDblClick Even Emitters not working properly #14161

siddhareddy opened this issue Nov 21, 2023 · 2 comments
Assignees

Comments

@siddhareddy
Copy link
Contributor

Describe the bug

In the p-listbox when we have onClick or onDblClick event emitters, wrong values are getting emitted

In the below example, when I click on the New York selection. It emits empty value
image

When I change the item selected to i.e Rome. It shows the older selected value
image

Same issue when using the onDblClick.

Environment

Operating System : Windows 10
PrimeNG Version: 16.8.0
Angular Version: 16.2.12

Reproducer

https://stackblitz.com/edit/rjbvrn?file=src%2Fapp%2Fdemo%2Flistbox-basic-demo.html

Angular version

16.2.12

PrimeNG version

16.8.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

16

Browser(s)

Chrome 119

Steps to reproduce the behavior

  1. Go to the demo https://stackblitz.com/edit/rjbvrn?file=src%2Fapp%2Fdemo%2Flistbox-basic-demo.html
  2. Click NewYork option and you get empty value
  3. Click Rome option and you will get NewYork as a result

Expected behavior

No response

@siddhareddy siddhareddy 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
@cetincakiroglu
Copy link
Contributor

Thanks a lot for reporting the issue

@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 21, 2023
@cetincakiroglu cetincakiroglu self-assigned this Nov 21, 2023
@cetincakiroglu cetincakiroglu added this to the 16.9.0 milestone Nov 21, 2023
@cetincakiroglu
Copy link
Contributor

cetincakiroglu commented Nov 21, 2023

Hi,

We've checked the previous version and the current version and we've found that onClick and onChange emitters implemented wrongly. Flow should be like this:

1-) User clicks a value
2-) onClick emitter fired with the clicked option, in this step nothing is written to the model value yet. That's why your binding remains undefined.
3-) writeValue method triggered to write value to the model (selectedCity in this case), in this step your binding receives the value.
4-) onChange emitter fired with the current value of the model.

If you check the previous versions for example 16.4x, you'll see that onClick is emitted after onChange which was wrong behavior. The model value shouldn't be written on click, it should change after the click.

The previous implementation was wrong, the current one is fixed and works as it should be, thanks a lot for the feedback.

@cetincakiroglu cetincakiroglu removed the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Nov 21, 2023
@cetincakiroglu cetincakiroglu removed this from the 16.9.0 milestone Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants