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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/radio/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
31 changes: 25 additions & 6 deletions src/radio/__tests__/radio.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,32 @@ describe('RadioGroup', () => {

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

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