From 65335523dde9a3afd3af045ea01c2e4dd19a1e2f Mon Sep 17 00:00:00 2001 From: Melloware Date: Mon, 14 Nov 2022 08:35:39 -0500 Subject: [PATCH] Fix #3636: Radiobutton fire onChange only if chnaged (#3637) --- components/lib/radiobutton/RadioButton.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/lib/radiobutton/RadioButton.js b/components/lib/radiobutton/RadioButton.js index 329505632d..746a03bdae 100644 --- a/components/lib/radiobutton/RadioButton.js +++ b/components/lib/radiobutton/RadioButton.js @@ -18,7 +18,7 @@ export const RadioButton = React.memo( const radioClicked = e.target instanceof HTMLDivElement; const inputClicked = e.target === inputRef.current; const isInputToggled = inputClicked && e.target.checked !== checked; - const isRadioToggled = radioClicked && !e.target.checked; + const isRadioToggled = radioClicked && (DomHandler.hasClass(elementRef.current, 'p-radiobutton-checked') === checked ? !checked : false); if (isInputToggled || isRadioToggled) { const value = !checked; @@ -37,6 +37,10 @@ export const RadioButton = React.memo( checked: value } }); + + if (isRadioToggled) { + inputRef.current.checked = value; + } } DomHandler.focus(inputRef.current);