p-checkbox firing onClick
event twice when clicking the label if inputId
is populated
#14487
Labels
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
Describe the bug
Clicking the label does not check/uncheck the checkbox. It appears to only be happening when a value is passed into the
inputId
parameter.The reason is because
onClick()
is set to be called twice: once from the parentdiv
and once from thelabel
and passinginputId
binds the label (withfor="..."
) to the checkbox.Environment
Latest Angular + PrimeNg, easily reproducible (see the StackBlitz link below)
Reproducer
https://stackblitz.com/edit/github-bnmzm9
Angular version
17.0.8
PrimeNG version
17.3.1
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
18.13.0
Browser(s)
Brave Version 1.61.109 Chromium: 120.0.6099.144
Steps to reproduce the behavior
p-checkbox
component with the following properties:inputId
,label
checked
state does not changechecked
state changesExpected behavior
Clicking either the
label
or the checkbox input should flip thechecked
stateThe text was updated successfully, but these errors were encountered: