Skip to content

Commit

Permalink
Merge pull request #6224 from melloware/PR6223
Browse files Browse the repository at this point in the history
Fix #6223: RadioButton onChange called twice
  • Loading branch information
nitrogenous authored Mar 26, 2024
2 parents 4cafa77 + d05353d commit db3d6cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion components/lib/checkbox/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const Checkbox = React.memo(
}
};

props.onChange && props.onChange(eventData);
props?.onChange?.(eventData);

// do not continue if the user defined click wants to prevent
if (event.defaultPrevented) {
Expand Down
14 changes: 6 additions & 8 deletions components/lib/radiobutton/RadioButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,14 @@ export const RadioButton = React.memo(
}
};

props?.onChange?.(eventData);

// do not continue if the user defined click wants to prevent
if (event.defaultPrevented) {
return;
}

if (isInputToggled || isRadioToggled) {
props?.onChange?.(eventData);

// do not continue if the user defined click wants to prevent
if (event.defaultPrevented) {
return;
}

if (isRadioToggled) {
inputRef.current.checked = value;
}
Expand Down Expand Up @@ -163,7 +161,7 @@ export const RadioButton = React.memo(

return (
<div {...boxProps}>
<div {...iconProps}></div>
<div {...iconProps} />
</div>
);
};
Expand Down

0 comments on commit db3d6cb

Please sign in to comment.