fix: avoid fixedblock height working in popup (#1621)

* fix: designer item should return null

* fix: avoid fixedblock height working in popup
This commit is contained in:
Dunqing 2023-03-30 15:33:05 +08:00 committed by GitHub
parent 6b47597256
commit 35d34bb427
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,17 +42,20 @@ export const FixedBlockWrapper: React.FC = (props) => {
const fixedBlock = useFixedSchema(); const fixedBlock = useFixedSchema();
const { height, fixedBlockUID } = useFixedBlock(); const { height, fixedBlockUID } = useFixedBlock();
const record = useRecord(); const record = useRecord();
const isPopup = Object.keys(record); const isPopup = Object.keys(record).length;
if (isPopup) {
return <>{props.children}</>;
}
/** /**
* The fixedBlockUID of false means that the page has no fixed blocks * The fixedBlockUID of false means that the page has no fixed blocks
* isPopup means that the FixedBlock is in the popup mode * isPopup means that the FixedBlock is in the popup mode
*/ */
if (!fixedBlock && fixedBlockUID && !isPopup) return null; if (!fixedBlock && fixedBlockUID) return null;
return ( return (
<div <div
className="nb-fixed-block" className="nb-fixed-block"
style={{ style={{
height: fixedBlockUID !== false ? `calc(100vh - ${height}px)` : undefined, height: fixedBlockUID ? `calc(100vh - ${height}px)` : undefined,
}} }}
> >
{props.children} {props.children}
@ -67,9 +70,8 @@ export const FixedBlockDesignerItem = () => {
const { dn } = useDesignable(); const { dn } = useDesignable();
const record = useRecord(); const record = useRecord();
return useMemo(() => {
if (Object.keys(record).length) { if (Object.keys(record).length) {
return; return null;
} }
return ( return (
<SchemaSettings.SwitchItem <SchemaSettings.SwitchItem
@ -90,7 +92,6 @@ export const FixedBlockDesignerItem = () => {
}} }}
/> />
); );
}, [fieldSchema['x-decorator-props'], field.decoratorProps?.fixedBlock, dn, record]);
}; };
interface FixedBlockProps { interface FixedBlockProps {