Browse Source

fix(card): tab size extend card size(#42176) (#42183)

pull/42203/head
huangkairan 2 years ago
committed by GitHub
parent
commit
7006b3799c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      components/card/Card.tsx
  2. 33
      components/card/__tests__/index.test.tsx

5
components/card/Card.tsx

@ -116,10 +116,12 @@ const Card = React.forwardRef((props: CardProps, ref: React.Ref<HTMLDivElement>)
};
let head: React.ReactNode;
const mergedSize = customizeSize || size;
const tabSize = !mergedSize || mergedSize === 'default' ? 'large' : mergedSize;
const tabs =
tabList && tabList.length ? (
<Tabs
size="large"
size={tabSize}
{...extraProps}
className={`${prefixCls}-head-tabs`}
onChange={onTabChange}
@ -152,7 +154,6 @@ const Card = React.forwardRef((props: CardProps, ref: React.Ref<HTMLDivElement>)
<ul className={`${prefixCls}-actions`}>{getAction(actions)}</ul>
) : null;
const divProps = omit(others, ['onTabChange']);
const mergedSize = customizeSize || size;
const classString = classNames(
prefixCls,
{

33
components/card/__tests__/index.test.tsx

@ -87,6 +87,39 @@ describe('Card', () => {
expect(container.querySelectorAll('.ant-tabs-small').length === 0).toBeFalsy();
});
it('tab size extend card size', () => {
const { container: largeContainer } = render(
<Card
title="Card title"
tabList={[
{
key: 'key',
tab: 'tab',
},
]}
>
<p>Card content</p>
</Card>,
);
expect(largeContainer.querySelectorAll('.ant-tabs-large').length === 0).toBeFalsy();
const { container } = render(
<Card
title="Card title"
tabList={[
{
key: 'key',
tab: 'tab',
},
]}
size='small'
>
<p>Card content</p>
</Card>,
);
expect(container.querySelectorAll('.ant-tabs-small').length === 0).toBeFalsy();
});
it('get ref of card', () => {
const cardRef = React.createRef<HTMLDivElement>();

Loading…
Cancel
Save