Skip to content
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
85 changes: 44 additions & 41 deletions src/TabPanelList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,50 @@ const TabPanelList: React.FC<TabPanelListProps> = props => {

return (
<div className={clsx(`${prefixCls}-content-holder`)}>
<div
className={clsx(`${prefixCls}-content`, `${prefixCls}-content-${tabPosition}`, {
[`${prefixCls}-content-animated`]: tabPaneAnimated,
Comment thread
selicens marked this conversation as resolved.
})}
>
{tabs.map(item => {
const {
key,
forceRender,
style: paneStyle,
className: paneClassName,
destroyOnHidden: itemDestroyOnHidden,
...restTabProps
} = item;
const active = key === activeKey;
return (
<CSSMotion
key={key}
visible={active}
forceRender={forceRender}
removeOnLeave={!!(destroyOnHidden ?? itemDestroyOnHidden)}
leavedClassName={`${tabPanePrefixCls}-hidden`}
{...animated.tabPaneMotion}
>
{({ style: motionStyle, className: motionClassName }, ref) => (
<TabPane
{...restTabProps}
prefixCls={tabPanePrefixCls}
id={id}
tabKey={key}
animated={tabPaneAnimated}
active={active}
style={{ ...contentStyle, ...paneStyle, ...motionStyle }}
className={clsx(contentClassName, paneClassName, motionClassName)}
ref={ref}
/>
)}
</CSSMotion>
);
})}
</div>
{tabs.map(item => {
const {
key,
forceRender,
style: paneStyle,
className: paneClassName,
destroyOnHidden: itemDestroyOnHidden,
...restTabProps
} = item;
const active = key === activeKey;
return (
<CSSMotion
key={key}
visible={active}
forceRender={forceRender}
removeOnLeave={!!(destroyOnHidden ?? itemDestroyOnHidden)}
leavedClassName={`${tabPanePrefixCls}-hidden`}
{...animated.tabPaneMotion}
>
{({ style: motionStyle, className: motionClassName }, ref) => (
<TabPane
{...restTabProps}
prefixCls={tabPanePrefixCls}
id={id}
tabKey={key}
animated={tabPaneAnimated}
active={active}
style={{ ...contentStyle, ...paneStyle, ...motionStyle }}
className={clsx(
`${prefixCls}-content`,
`${prefixCls}-content-${tabPosition}`,
{
[`${prefixCls}-content-animated`]: tabPaneAnimated,
},
contentClassName,
paneClassName,
motionClassName,
)}
Comment thread
selicens marked this conversation as resolved.
ref={ref}
/>
)}
</CSSMotion>
);
})}
</div>
);
};
Expand Down
36 changes: 14 additions & 22 deletions tests/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,14 @@ exports[`Tabs.Basic Normal 1`] = `
class="rc-tabs-content-holder"
>
<div
class="rc-tabs-content rc-tabs-content-top"
aria-hidden="false"
aria-labelledby="rc-tabs-test-tab-bamboo"
class="rc-tabs-tabpane rc-tabs-tabpane-active rc-tabs-content rc-tabs-content-top"
id="rc-tabs-test-panel-bamboo"
role="tabpanel"
tabindex="0"
>
<div
aria-hidden="false"
aria-labelledby="rc-tabs-test-tab-bamboo"
class="rc-tabs-tabpane rc-tabs-tabpane-active"
id="rc-tabs-test-panel-bamboo"
role="tabpanel"
tabindex="0"
>
Bamboo
</div>
Bamboo
</div>
</div>
</div>
Expand Down Expand Up @@ -159,18 +155,14 @@ exports[`Tabs.Basic Skip invalidate children 1`] = `
class="rc-tabs-content-holder"
>
<div
class="rc-tabs-content rc-tabs-content-top"
aria-hidden="false"
aria-labelledby="rc-tabs-test-tab-light"
class="rc-tabs-tabpane rc-tabs-tabpane-active rc-tabs-content rc-tabs-content-top"
id="rc-tabs-test-panel-light"
role="tabpanel"
tabindex="0"
>
<div
aria-hidden="false"
aria-labelledby="rc-tabs-test-tab-light"
class="rc-tabs-tabpane rc-tabs-tabpane-active"
id="rc-tabs-test-panel-light"
role="tabpanel"
tabindex="0"
>
Light
</div>
Light
</div>
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions tests/mobile.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { render } from '@testing-library/react';
import { render, act } from '@testing-library/react';
import { spyElementPrototypes } from '@rc-component/util';
import React from 'react';
import { act } from 'react-dom/test-utils';
import type { TabsProps } from '../src';
import Tabs from '../src';
import { btnOffsetPosition, getOffsetSizeFunc, getTransformX } from './common/util';
Expand Down
3 changes: 1 addition & 2 deletions tests/operation-overflow.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-invalid-this */
import { render } from '@testing-library/react';
import { render, act } from '@testing-library/react';
import { spyElementPrototypes } from '@rc-component/util';
import { act } from 'react-dom/test-utils';
import { getOffsetSizeFunc, getTabs, triggerResize } from './common/util';

describe('Tabs.Operation-Overflow', () => {
Expand Down
3 changes: 1 addition & 2 deletions tests/rtl.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { render, act } from '@testing-library/react';
import { spyElementPrototypes } from '@rc-component/util';
import { act } from 'react-dom/test-utils';
import { getOffsetSizeFunc, getTabs, getTransformX, triggerResize } from './common/util';

// Same as `overflow.test.tsx` but use in RTL
Expand Down