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

Component: Checkbox #15033

Closed
lemonCMS opened this issue Mar 13, 2024 · 4 comments
Closed

Component: Checkbox #15033

lemonCMS opened this issue Mar 13, 2024 · 4 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@lemonCMS
Copy link

lemonCMS commented Mar 13, 2024

Describe the bug

Update triggered twice

When having a p-checkbox with a formControl and the value attribute populated, then the control get updated twice

` <p-checkbox
[formControl]="fc2"
[value]="1"
inputId="binary"
[label]="'Label 2'"

`

this.fc2.valueChanges.subscribe(console.log);

Clicking the checkbox will result in two updates.

When you have the checkbox set to binary this does not happen.

Environment

The primeNG test environment

Reproducer

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

Angular version

17

PrimeNG version

17

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.8.0

Browser(s)

Chrome

Steps to reproduce the behavior

See the provided example repo

Expected behavior

To only receive one update

@lemonCMS lemonCMS added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Mar 13, 2024
@abdallahmmu
Copy link

abdallahmmu commented Mar 13, 2024

remove the value property binding of 1 and make sure your initial value throw the formControl it will take the job and make the binding

@lemonCMS
Copy link
Author

We need to have the value property binding. In the my example only one checkbox is shown, but in the application we have a list of checkboxes binded to the same formControl.

@abdallahmmu
Copy link

if so you need to bind all the checkboxes to the same form control but keep in mind this will reflect all the checkboxes value once any one triggered to true.

also if you try to make a multiple choices using checkboxes then I suggest to use a form array. instead of form control

@mehmetcetin01140
Copy link
Contributor

Hi,

So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you open a new issue so we can include it in our roadmap?

Thanks a lot for your understanding!
Best Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

3 participants