Skip to content

Commit

Permalink
fix(layout): remove extra dom node (#3631)
Browse files Browse the repository at this point in the history
* fix(form): fix transform no support lableInValue

* fix test

* fix(layout): remove auto fix error

* remov snapshot
  • Loading branch information
chenshuai2144 authored Sep 9, 2021
1 parent dfc1608 commit d89667e
Show file tree
Hide file tree
Showing 6 changed files with 7,856 additions and 7,999 deletions.
47 changes: 27 additions & 20 deletions packages/layout/src/components/PageContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PageHeader, Tabs, Affix, ConfigProvider, Breadcrumb } from 'antd';
import type { ReactNode } from 'react';
import React, { useContext } from 'react';
import React, { useContext, useMemo } from 'react';
import classNames from 'classnames';
import type {
TabsProps,
Expand Down Expand Up @@ -215,11 +215,16 @@ const ProPageHeader: React.FC<PageContainerProps & { prefixedClassName: string }
const { breadcrumb } = pageHeaderProps as {
breadcrumb: BreadcrumbProps;
};
const noHasBreadCrumb =
!breadcrumb ||
breadcrumbRender === false ||
(!breadcrumb?.itemRender && !breadcrumb?.routes?.length);

if (
['title', 'subTitle', 'breadcrumb', 'extra', 'tags', 'footer', 'avatar', 'backIcon'].every(
['title', 'subTitle', 'extra', 'tags', 'footer', 'avatar', 'backIcon'].every(
(item) => !pageHeaderProps[item],
) &&
(!breadcrumb || (!breadcrumb?.itemRender && !breadcrumb?.routes?.length)) &&
noHasBreadCrumb &&
!content &&
!extraContent
) {
Expand Down Expand Up @@ -267,20 +272,21 @@ const PageContainer: React.FC<PageContainerProps> = (props) => {
[`${prefixCls}-page-container-with-footer`]: footer,
});

const content = children ? (
<div>
<div className={`${prefixedClassName}-children-content`}>{children}</div>
{value.hasFooterToolbar && (
<div
style={{
height: 48,
marginTop: 24,
}}
/>
)}
</div>
) : null;

const content = useMemo(() => {
return children ? (
<>
<div className={`${prefixedClassName}-children-content`}>{children}</div>
{value.hasFooterToolbar && (
<div
style={{
height: 48,
marginTop: 24,
}}
/>
)}
</>
) : null;
}, [children, prefixedClassName, value.hasFooterToolbar]);
const pageHeaderDom = (
<ProPageHeader
{...restProps}
Expand All @@ -290,14 +296,15 @@ const PageContainer: React.FC<PageContainerProps> = (props) => {
/>
);

const renderContent = () => {
const renderContentDom = useMemo(() => {
const spinProps = genLoading(loading);
const dom = spinProps.spinning ? <PageLoading {...spinProps} /> : content;
if (props.waterMarkProps || value.waterMarkProps) {
return <WaterMark {...(props.waterMarkProps || value.waterMarkProps)}>{dom}</WaterMark>;
}
return dom;
};
}, [content, loading, props.waterMarkProps, value.waterMarkProps]);

return (
<div style={style} className={containerClassName}>
{fixedHeader && pageHeaderDom ? (
Expand All @@ -311,7 +318,7 @@ const PageContainer: React.FC<PageContainerProps> = (props) => {
) : (
pageHeaderDom
)}
<GridContent>{renderContent()}</GridContent>
{renderContentDom && <GridContent>{renderContentDom}</GridContent>}
{footer && <FooterToolbar prefixCls={prefixCls}>{footer}</FooterToolbar>}
</div>
);
Expand Down
Loading

0 comments on commit d89667e

Please sign in to comment.