Skip to content

Commit 9b6bf4a

Browse files
authored
fix(tabs): disabled animated when tabPosition is left/right (#5464)
* fix(tabs): disabled animated when tabPosition is left/right * fix(tabs): disabled animated when tabPosition is left/right * test: update test * test: update test & position demo
1 parent 0c80321 commit 9b6bf4a

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

components/tabs/__tests__/__snapshots__/demo.test.js.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,12 @@ exports[`renders ./components/tabs/demo/position.vue correctly 1`] = `
452452
<!---->
453453
</div>
454454
<div class="ant-tabs-content-holder">
455-
<div class="ant-tabs-content ant-tabs-content-top">
455+
<div class="ant-tabs-content ant-tabs-content-top ant-tabs-content-animated">
456456
<div role="tabpanel" tabindex="0" aria-hidden="false" class="ant-tabs-tabpane ant-tabs-tabpane-active" id="rc-tabs-test-panel-1" aria-labelledby="rc-tabs-test-tab-1">Content of Tab 1</div>
457-
<div role="tabpanel" tabindex="-1" aria-hidden="true" style="display: none;" class="ant-tabs-tabpane" id="rc-tabs-test-panel-2" aria-labelledby="rc-tabs-test-tab-2">
457+
<div role="tabpanel" tabindex="-1" aria-hidden="true" style="visibility: hidden; height: 0px; overflow-y: hidden;" class="ant-tabs-tabpane" id="rc-tabs-test-panel-2" aria-labelledby="rc-tabs-test-tab-2">
458458
<!---->
459459
</div>
460-
<div role="tabpanel" tabindex="-1" aria-hidden="true" style="display: none;" class="ant-tabs-tabpane" id="rc-tabs-test-panel-3" aria-labelledby="rc-tabs-test-tab-3">
460+
<div role="tabpanel" tabindex="-1" aria-hidden="true" style="visibility: hidden; height: 0px; overflow-y: hidden;" class="ant-tabs-tabpane" id="rc-tabs-test-panel-3" aria-labelledby="rc-tabs-test-tab-3">
461461
<!---->
462462
</div>
463463
</div>

components/tabs/__tests__/__snapshots__/index.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ exports[`Tabs tabPosition remove card 1`] = `
1111
<!---->
1212
</div>
1313
<!---->
14-
<div class="ant-tabs-ink-bar ant-tabs-ink-bar-animated"></div>
14+
<div class="ant-tabs-ink-bar"></div>
1515
</div>
1616
</div>
1717
<div class="ant-tabs-nav-operations ant-tabs-nav-operations-hidden">

components/tabs/demo/position.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Tab's position: left, right, top or bottom. Will auto switch to `top` in mobile
2323
<a-radio-button value="left">left</a-radio-button>
2424
<a-radio-button value="right">right</a-radio-button>
2525
</a-radio-group>
26-
<a-tabs v-model:activeKey="activeKey" :tab-position="tabPosition">
26+
<a-tabs v-model:activeKey="activeKey" :tab-position="tabPosition" animated>
2727
<a-tab-pane key="1" tab="Tab 1">Content of Tab 1</a-tab-pane>
2828
<a-tab-pane key="2" tab="Tab 2">Content of Tab 2</a-tab-pane>
2929
<a-tab-pane key="3" tab="Tab 3">Content of Tab 3</a-tab-pane>

components/tabs/index.en-US.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Ant Design has 3 types of Tabs for different situations.
2222
| Property | Description | Type | Default | Version |
2323
| --- | --- | --- | --- | --- |
2424
| activeKey(v-model) | Current TabPane's key | string | - | |
25-
| animated | Whether to change tabs with animation. Only works while `tabPosition="top"\|"bottom"` | boolean \| {inkBar:boolean, tabPane:boolean} | `true`, `false` when `type="card"` | |
25+
| animated | Whether to change tabs with animation. Only works while tabPosition=`"top"` \| `"bottom"` | boolean \| {inkBar:boolean, tabPane:boolean} | `true`, `false` when `type="card"` | |
2626
| destroyInactiveTabPane | Whether destroy inactive TabPane when change tab | boolean | false | |
2727
| hideAdd | Hide plus icon or not. Only works while `type="editable-card"` | boolean | `false` | } |
2828
| size | preset tab bar size | `large` \| `default` \| `small` | `default` | |

components/tabs/index.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Ant Design 依次提供了三级选项卡,分别用于不同的场景。
2525
| 参数 | 说明 | 类型 | 默认值 | 版本 | |
2626
| --- | --- | --- | --- | --- | --- |
2727
| activeKey(v-model) | 当前激活 tab 面板的 key | string || | |
28-
| animated | 是否使用动画切换 Tabs,在 \`tabPosition=top | bottom\` 时有效 | boolean \| {inkBar:boolean, tabPane:boolean} | true, 当 type="card" 时为 false | |
28+
| animated | 是否使用动画切换 Tabs,在 tabPosition=`"top"` \| `"bottom"` 时有效 | boolean \| {inkBar:boolean, tabPane:boolean} | true, 当 type="card" 时为 false | |
2929
| centered | 标签居中展示 | boolean | false | 3.0 | |
3030
| destroyInactiveTabPane | 被隐藏时是否销毁 DOM 结构 | boolean | false | | |
3131
| hideAdd | 是否隐藏加号图标,在 `type="editable-card"` 时有效 | boolean | false | | |

components/tabs/src/Tabs.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ const InternalTabs = defineComponent({
155155
const { prefixCls, direction, size, rootPrefixCls } = useConfigInject('tabs', props);
156156
const rtl = computed(() => direction.value === 'rtl');
157157
const mergedAnimated = computed<AnimatedConfig>(() => {
158-
const { animated } = props;
159-
if (animated === false) {
158+
const { animated, tabPosition } = props;
159+
if (animated === false || ['left', 'right'].includes(tabPosition)) {
160160
return {
161161
inkBar: false,
162162
tabPane: false,

0 commit comments

Comments
 (0)