Skip to content

Commit

Permalink
chore: Use overflow to hide the tab pane in !animated
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Jun 9, 2020
1 parent 1a15766 commit 6b2c25c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/TabPanelList/TabPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ export default function TabPane({

const mergedStyle: React.CSSProperties = {};
if (!active) {
if (animated) {
mergedStyle.visibility = 'hidden';
} else {
mergedStyle.display = 'none';
mergedStyle.visibility = 'hidden';

if (!animated) {
mergedStyle.height = 0;
mergedStyle.overflowY = 'hidden';
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/TabPanelList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ export default function TabPanelList({
className={classNames(`${prefixCls}-content`, `${prefixCls}-content-${tabPosition}`, {
[`${prefixCls}-content-animated`]: tabPaneAnimated,
})}
style={
tabPaneAnimated ? { [rtl ? 'marginRight' : 'marginLeft']: `-${activeIndex}00%` } : null
}
style={{ [rtl ? 'marginRight' : 'marginLeft']: `-${activeIndex}00%` }}
>
{tabs.map(tab => {
return React.cloneElement(tab.node, {
Expand Down
6 changes: 4 additions & 2 deletions tests/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ exports[`Tabs.Basic Normal 1`] = `
>
<div
class="rc-tabs-content rc-tabs-content-top"
style="margin-left: -100%;"
>
<div
aria-hidden="true"
aria-labelledby="rc-tabs-test-tab-light"
class="rc-tabs-tabpane"
id="rc-tabs-test-panel-light"
role="tabpanel"
style="display: none;"
style="visibility: hidden; height: 0px; overflow-y: hidden;"
tabindex="-1"
/>
<div
Expand All @@ -102,7 +103,7 @@ exports[`Tabs.Basic Normal 1`] = `
class="rc-tabs-tabpane"
id="rc-tabs-test-panel-cute"
role="tabpanel"
style="display: none;"
style="visibility: hidden; height: 0px; overflow-y: hidden;"
tabindex="-1"
/>
</div>
Expand Down Expand Up @@ -164,6 +165,7 @@ exports[`Tabs.Basic Skip invalidate children 1`] = `
>
<div
class="rc-tabs-content rc-tabs-content-top"
style="margin-left: -000%;"
>
<div
aria-hidden="false"
Expand Down

0 comments on commit 6b2c25c

Please sign in to comment.