mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 11:40:04 +08:00
Merge pull request #16510 from yociduo/master
fix(PageHeader): Should not render blank dom
This commit is contained in:
commit
db8c54e17e
@ -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"
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user