fix: tabs key support 0 as key #2167
							parent
							
								
									fd28043172
								
							
						
					
					
						commit
						a28962bfe7
					
				| 
						 | 
				
			
			@ -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