mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 04:30:06 +08:00
fix: children of Tabs[type="editable-card"] cannot be falsy (#17965)
* tabs-editable-card-bugfix if tabs type ="editable-card",if children has falsy value ,we will get error message,so we should fix it in tabs. error:https://codesandbox.io/s/lively-glade-jmg5s * editable-card bugfix * tabs bugfix * tabs-editable-card bugfix * tab bugfix * bugfix * delete errorfix * add test
This commit is contained in:
parent
facc7124da
commit
5a7a92af46
@ -16,6 +16,9 @@ describe('Tabs', () => {
|
|||||||
<TabPane tab="foo" key="1">
|
<TabPane tab="foo" key="1">
|
||||||
foo
|
foo
|
||||||
</TabPane>
|
</TabPane>
|
||||||
|
{undefined}
|
||||||
|
{null}
|
||||||
|
{false}
|
||||||
</Tabs>,
|
</Tabs>,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -32,6 +35,10 @@ describe('Tabs', () => {
|
|||||||
wrapper.find('.anticon-close').simulate('click');
|
wrapper.find('.anticon-close').simulate('click');
|
||||||
expect(handleEdit).toHaveBeenCalledWith('1', 'remove');
|
expect(handleEdit).toHaveBeenCalledWith('1', 'remove');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('validateElement', () => {
|
||||||
|
expect(wrapper.find('.ant-tabs-tab').length).toBe(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('tabPosition', () => {
|
describe('tabPosition', () => {
|
||||||
|
@ -129,9 +129,8 @@ export default class Tabs extends React.Component<TabsProps, any> {
|
|||||||
let childrenWithClose: React.ReactElement<any>[] = [];
|
let childrenWithClose: React.ReactElement<any>[] = [];
|
||||||
if (type === 'editable-card') {
|
if (type === 'editable-card') {
|
||||||
childrenWithClose = [];
|
childrenWithClose = [];
|
||||||
React.Children.forEach(
|
React.Children.forEach(children as React.ReactNode, (child, index) => {
|
||||||
children as React.ReactNode,
|
if (!React.isValidElement(child)) return child;
|
||||||
(child: React.ReactElement<any>, index) => {
|
|
||||||
let closable = child.props.closable;
|
let closable = child.props.closable;
|
||||||
closable = typeof closable === 'undefined' ? true : closable;
|
closable = typeof closable === 'undefined' ? true : closable;
|
||||||
const closeIcon = closable ? (
|
const closeIcon = closable ? (
|
||||||
@ -152,8 +151,7 @@ export default class Tabs extends React.Component<TabsProps, any> {
|
|||||||
key: child.key || index,
|
key: child.key || index,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
// Add new tab handler
|
// Add new tab handler
|
||||||
if (!hideAdd) {
|
if (!hideAdd) {
|
||||||
tabBarExtraContent = (
|
tabBarExtraContent = (
|
||||||
|
Loading…
Reference in New Issue
Block a user