mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-02 12:07:54 +08:00
fix: tabs key support 0 as key #2167
This commit is contained in:
parent
fd28043172
commit
a28962bfe7
4
components/_util/isValid.js
Normal file
4
components/_util/isValid.js
Normal file
@ -0,0 +1,4 @@
|
||||
const isValid = value => {
|
||||
return value !== undefined && value !== null && value !== '';
|
||||
};
|
||||
export default isValid;
|
@ -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);
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user