Fix Listbox checkbox toggle desync when clicking option label #19275
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug Description
In
Listboxwithmultipleselection enabled andcheckboxmode active,the checkbox visual state could become out of sync with the actual selected
option state.
When clicking on the option label or the
<li>element, the selection wasupdated correctly, but the checkbox component could toggle independently,
leading to an inconsistent UI state.
Root Cause
p-checkboxwas still handling its own internal toggle logic while theListbox component was also controlling selection state via option clicks.
This caused the checkbox to update separately from the Listbox selection
logic.
Fix
The checkbox is now marked as
readonlyto prevent it from managing itsown state. The Listbox remains the single source of truth for selection,
and the checkbox becomes a purely visual indicator of the selected state.
Reproduction Steps
Use p-listbox with multiple="true" and checkbox="true"
Click on the option label or list item
Observe checkbox toggling independently of selection state
Affected Version
PrimeNG 18.x
Expected Behavior
Checkbox state should always stay in sync with the selected options.