Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(radio): group can't render outline variant by options prop #2613

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(radio): group can't render outline variant by options prop
  • Loading branch information
NWYLZW committed Nov 25, 2023
commit 3e4564ec0e38779d814f2588f018b0c935484c4f
2 changes: 1 addition & 1 deletion src/radio/RadioGroup.tsx
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ const RadioGroup = (props: RadioGroupProps) => {
};

const renderOptions = () => {
const Comp = variant.includes('filled') ? Radio.Button : Radio;
const Comp = variant.includes('filled') || variant === 'outline' ? Radio.Button : Radio;
return options.map((item) => {
let label: ReactNode;
let value: string | number;
26 changes: 20 additions & 6 deletions src/radio/__tests__/radio.test.tsx
Original file line number Diff line number Diff line change
@@ -81,13 +81,27 @@ describe('RadioGroup', () => {

test('variant', () => {
const { container } = render(
<Radio.Group
variant="primary-filled"
defaultValue="北京"
options={[{ value: '上海', label: '上海' }, { value: '广州', label: '广州', disabled: true }, '北京', 1]}
/>,
<>
<Radio.Group
variant="outline"
defaultValue="北京"
options={[{ value: '上海', label: '上海' }, { value: '广州', label: '广州', disabled: true }, '北京', 1]}
/>
<Radio.Group
variant="primary-filled"
defaultValue="北京"
options={[{ value: '上海', label: '上海' }, { value: '广州', label: '广州', disabled: true }, '北京', 1]}
/>
<Radio.Group
variant="default-filled"
defaultValue="北京"
options={[{ value: '上海', label: '上海' }, { value: '广州', label: '广州', disabled: true }, '北京', 1]}
/>
</>,
);
expect(container.firstChild.firstChild).toHaveClass('t-radio-button');
for (const item of container.children) {
expect(item.firstChild).toHaveClass('t-radio-button');
}
});

test('value is string', () => {
Loading