fix: tabs key support 0 as key #2167

This commit is contained in:
tanjinzhou 2020-04-29 11:35:25 +08:00
parent fd28043172
commit a28962bfe7
3 changed files with 9 additions and 4 deletions

View File

@ -0,0 +1,4 @@
const isValid = value => {
return value !== undefined && value !== null && value !== '';
};
export default isValid;

View File

@ -72,11 +72,11 @@ const TabBar = {
if (renderTabBar) {
RenderTabBar = renderTabBar(renderProps, ScrollableInkTabBar);
// https://github.com/vueComponent/ant-design-vue/issues/2157
return cloneElement(RenderTabBar, renderProps);
} else {
RenderTabBar = <ScrollableInkTabBar {...renderProps} />;
return <ScrollableInkTabBar {...renderProps} />;
}
// https://github.com/vueComponent/ant-design-vue/issues/2157
return cloneElement(RenderTabBar, renderProps);
},
};

View File

@ -6,12 +6,13 @@ import KeyCode from './KeyCode';
import { getOptionProps, getListeners } from '../../_util/props-util';
import { cloneElement } from '../../_util/vnode';
import Sentinel from './Sentinel';
import isValid from '../../_util/isValid';
function getDefaultActiveKey(props) {
let activeKey;
const children = props.children;
children.forEach(child => {
if (child && !activeKey && !child.disabled) {
if (child && !isValid(activeKey) && !child.disabled) {
activeKey = child.key;
}
});