Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(PageHeader): Should not render blank dom #16510

Merged
merged 2 commits into from
May 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 5 additions & 0 deletions components/page-header/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
19 changes: 11 additions & 8 deletions components/page-header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down