Skip to content

Commit b0f1c74

Browse files
authored
fix(RadioGroup): reset bar style when no checked radio is found (#3944)
* fix(RadioGroup): reset bar style when no checked radio is found * chore(RadioGroup): prevent rendering background block when barStyle is not set * chore: update snapshots
1 parent 82ca669 commit b0f1c74

File tree

3 files changed

+121
-136
lines changed

3 files changed

+121
-136
lines changed

packages/components/radio/RadioGroup.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ const RadioGroup: React.FC<RadioGroupProps> = (originalProps) => {
7373
if (!variant.includes('filled')) return;
7474

7575
const checkedRadio = radioGroupRef.current.querySelector?.(checkedRadioCls) as HTMLElement;
76-
if (!checkedRadio) return;
76+
if (!checkedRadio) {
77+
setBarStyle(null);
78+
return;
79+
}
7780

7881
const { offsetWidth, offsetHeight, offsetLeft, offsetTop } = checkedRadio;
7982
setBarStyle({
@@ -112,7 +115,7 @@ const RadioGroup: React.FC<RadioGroupProps> = (originalProps) => {
112115
}, []); // eslint-disable-line react-hooks/exhaustive-deps
113116

114117
const renderBlock = () => {
115-
if (!variant.includes('filled')) {
118+
if (!variant.includes('filled') || !barStyle) {
116119
return null;
117120
}
118121
return <div style={barStyle} className={`${classPrefix}-radio-group__bg-block`}></div>;

0 commit comments

Comments
 (0)