Merge pull request #16510 from yociduo/master

fix(PageHeader): Should not render blank dom
This commit is contained in:
偏右 2019-05-10 00:00:51 +08:00 committed by GitHub
commit db8c54e17e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 8 deletions

View File

@ -1,5 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`PageHeader pageHeader should not render blank dom 1`] = `
<div
class="ant-page-header"
/>
`;
exports[`PageHeader pageHeader should support className 1`] = `
<div
class="ant-page-header not-works"

View File

@ -45,4 +45,9 @@ describe('PageHeader', () => {
);
expect(wrapper).toMatchSnapshot();
});
it('pageHeader should not render blank dom', () => {
const wrapper = render(<PageHeader title={false} />);
expect(wrapper).toMatchSnapshot();
});
});

View File

@ -68,14 +68,17 @@ const renderHeader = (prefixCls: string, props: PageHeaderProps) => {
const renderTitle = (prefixCls: string, props: PageHeaderProps) => {
const { title, subTitle, tags, extra } = props;
const titlePrefixCls = `${prefixCls}-title-view`;
return (
<div className={`${prefixCls}-title-view`}>
<span className={`${titlePrefixCls}-title`}>{title}</span>
{subTitle && <span className={`${titlePrefixCls}-sub-title`}>{subTitle}</span>}
{tags && <span className={`${titlePrefixCls}-tags`}>{tags}</span>}
{extra && <span className={`${titlePrefixCls}-extra`}>{extra}</span>}
</div>
);
if (title || subTitle || tags || extra) {
return (
<div className={`${prefixCls}-title-view`}>
{title && <span className={`${titlePrefixCls}-title`}>{title}</span>}
{subTitle && <span className={`${titlePrefixCls}-sub-title`}>{subTitle}</span>}
{tags && <span className={`${titlePrefixCls}-tags`}>{tags}</span>}
{extra && <span className={`${titlePrefixCls}-extra`}>{extra}</span>}
</div>
);
}
return null;
};
const renderFooter = (prefixCls: string, footer: React.ReactNode) => {