Skip to content

Commit a28962b

Browse files
committed
fix: tabs key support 0 as key #2167
1 parent fd28043 commit a28962b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

components/_util/isValid.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const isValid = value => {
2+
return value !== undefined && value !== null && value !== '';
3+
};
4+
export default isValid;

components/tabs/TabBar.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ const TabBar = {
7272

7373
if (renderTabBar) {
7474
RenderTabBar = renderTabBar(renderProps, ScrollableInkTabBar);
75+
// https://github.com/vueComponent/ant-design-vue/issues/2157
76+
return cloneElement(RenderTabBar, renderProps);
7577
} else {
76-
RenderTabBar = <ScrollableInkTabBar {...renderProps} />;
78+
return <ScrollableInkTabBar {...renderProps} />;
7779
}
78-
// https://github.com/vueComponent/ant-design-vue/issues/2157
79-
return cloneElement(RenderTabBar, renderProps);
8080
},
8181
};
8282

components/vc-tabs/src/Tabs.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import KeyCode from './KeyCode';
66
import { getOptionProps, getListeners } from '../../_util/props-util';
77
import { cloneElement } from '../../_util/vnode';
88
import Sentinel from './Sentinel';
9+
import isValid from '../../_util/isValid';
910

1011
function getDefaultActiveKey(props) {
1112
let activeKey;
1213
const children = props.children;
1314
children.forEach(child => {
14-
if (child && !activeKey && !child.disabled) {
15+
if (child && !isValid(activeKey) && !child.disabled) {
1516
activeKey = child.key;
1617
}
1718
});

0 commit comments

Comments
 (0)