Skip to content

Commit

Permalink
Fix #3636: Radiobutton fire onChange only if chnaged (#3637)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Nov 14, 2022
1 parent ddcf214 commit 6533552
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion components/lib/radiobutton/RadioButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,6 +37,10 @@ export const RadioButton = React.memo(
checked: value
}
});

if (isRadioToggled) {
inputRef.current.checked = value;
}
}

DomHandler.focus(inputRef.current);
Expand Down

0 comments on commit 6533552

Please sign in to comment.