<p-select> Support deselect the selected option by clicking on the option #3535
Unanswered
yongshun950824
asked this question in
PrimeNG
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Raised in this Stack Overflow question: How to Clear p-select Value When Clicking on the Selected Item in PrimeNG?.
Based on my study on the
onOptionClick
method, it only handles the option that is not previously selected and emits theonChange
event.Currently what I implement is to overwrite the existing
onOptionClick
method and add the logic to deselect the selected option (when clicking on the same option).Stack Overflow answer: https://stackoverflow.com/a/79423216/8017690
StackBlitz Demo: https://stackblitz.com/edit/bbzsyzyc?file=src%2Fapp%2Fselect-checkmark-demo.ts
I would like to propose to have a configuration for
<p-select>
, for example[allowDeselectOption]="true"
, and apply similar logic as attached above.Looking forward to the discussion of the proposal!
Thank you in advance.
Beta Was this translation helpful? Give feedback.
All reactions