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,30 +70,28 @@ 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 null;
return; }
} return (
return ( <SchemaSettings.SwitchItem
<SchemaSettings.SwitchItem title={t('Fix block')}
title={t('Fix block')} checked={fieldSchema['x-decorator-props']?.fixedBlock}
checked={fieldSchema['x-decorator-props']?.fixedBlock} onChange={async (fixedBlock) => {
onChange={async (fixedBlock) => { const decoratorProps = {
const decoratorProps = { ...fieldSchema['x-decorator-props'],
...fieldSchema['x-decorator-props'], fixedBlock,
fixedBlock, };
}; await dn.emit('patch', {
await dn.emit('patch', { schema: {
schema: { ['x-uid']: fieldSchema['x-uid'],
['x-uid']: fieldSchema['x-uid'], 'x-decorator-props': decoratorProps,
'x-decorator-props': decoratorProps, },
}, });
}); field.decoratorProps = fieldSchema['x-decorator-props'] = decoratorProps;
field.decoratorProps = fieldSchema['x-decorator-props'] = decoratorProps; }}
}} />
/> );
);
}, [fieldSchema['x-decorator-props'], field.decoratorProps?.fixedBlock, dn, record]);
}; };
interface FixedBlockProps { interface FixedBlockProps {