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 { height, fixedBlockUID } = useFixedBlock();
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
* isPopup means that the FixedBlock is in the popup mode
*/
if (!fixedBlock && fixedBlockUID && !isPopup) return null;
if (!fixedBlock && fixedBlockUID) return null;
return (
<div
className="nb-fixed-block"
style={{
height: fixedBlockUID !== false ? `calc(100vh - ${height}px)` : undefined,
height: fixedBlockUID ? `calc(100vh - ${height}px)` : undefined,
}}
>
{props.children}
@ -67,30 +70,28 @@ export const FixedBlockDesignerItem = () => {
const { dn } = useDesignable();
const record = useRecord();
return useMemo(() => {
if (Object.keys(record).length) {
return;
}
return (
<SchemaSettings.SwitchItem
title={t('Fix block')}
checked={fieldSchema['x-decorator-props']?.fixedBlock}
onChange={async (fixedBlock) => {
const decoratorProps = {
...fieldSchema['x-decorator-props'],
fixedBlock,
};
await dn.emit('patch', {
schema: {
['x-uid']: fieldSchema['x-uid'],
'x-decorator-props': decoratorProps,
},
});
field.decoratorProps = fieldSchema['x-decorator-props'] = decoratorProps;
}}
/>
);
}, [fieldSchema['x-decorator-props'], field.decoratorProps?.fixedBlock, dn, record]);
if (Object.keys(record).length) {
return null;
}
return (
<SchemaSettings.SwitchItem
title={t('Fix block')}
checked={fieldSchema['x-decorator-props']?.fixedBlock}
onChange={async (fixedBlock) => {
const decoratorProps = {
...fieldSchema['x-decorator-props'],
fixedBlock,
};
await dn.emit('patch', {
schema: {
['x-uid']: fieldSchema['x-uid'],
'x-decorator-props': decoratorProps,
},
});
field.decoratorProps = fieldSchema['x-decorator-props'] = decoratorProps;
}}
/>
);
};
interface FixedBlockProps {