mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 11:39:28 +08:00
fix(pageHeader): if title is null,no render title view
This commit is contained in:
parent
ea02c93c44
commit
ef5e6603c2
@ -50,6 +50,18 @@ describe('PageHeader', () => {
|
||||
expect(wrapper.find('.ant-page-header-back')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('pageHeader do not has title', () => {
|
||||
const routes = [
|
||||
{
|
||||
path: 'index',
|
||||
breadcrumbName: 'First-level Menu',
|
||||
},
|
||||
];
|
||||
const wrapper = mount(<PageHeader breadcrumb={{ routes }}>test</PageHeader>);
|
||||
expect(wrapper.find('.ant-page-header-heading-lef').exists()).toBeFalsy();
|
||||
expect(wrapper.find('.ant-page-header-heading').exists()).toBeFalsy();
|
||||
});
|
||||
|
||||
it('pageHeader should no contain back', () => {
|
||||
const wrapper = mount(<PageHeader title="Page Title" backIcon={false} />);
|
||||
expect(wrapper.find('.ant-page-header-back')).toHaveLength(0);
|
||||
|
@ -72,8 +72,11 @@ const renderTitle = (prefixCls: string, props: PageHeaderProps, direction: strin
|
||||
if (title || subTitle || tags || extra) {
|
||||
const backIcon = getBackIcon(props, direction);
|
||||
const backIconDom = renderBack(prefixCls, backIcon, onBack);
|
||||
const hasTitle = backIconDom || avatar || title || subTitle || tags || extra;
|
||||
return (
|
||||
hasTitle && (
|
||||
<div className={headingPrefixCls}>
|
||||
{hasTitle && (
|
||||
<div className={`${headingPrefixCls}-left`}>
|
||||
{backIconDom}
|
||||
{avatar && <Avatar {...avatar} />}
|
||||
@ -95,8 +98,10 @@ const renderTitle = (prefixCls: string, props: PageHeaderProps, direction: strin
|
||||
)}
|
||||
{tags && <span className={`${headingPrefixCls}-tags`}>{tags}</span>}
|
||||
</div>
|
||||
)}
|
||||
{extra && <span className={`${headingPrefixCls}-extra`}>{extra}</span>}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user