fix: disappearing of fixed-block option (#2914)

This commit is contained in:
被雨水过滤的空气-Rain 2023-10-25 22:50:28 +08:00 committed by GitHub
parent bbe7eed314
commit b8bc32f421
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 6 deletions

View File

@ -1,10 +1,11 @@
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
import { useField, useFieldSchema } from '@formily/react';
import { css } from '@emotion/css';
import { SchemaSettings } from '../../../schema-settings';
import { useField, useFieldSchema } from '@formily/react';
import React, { useContext, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useDesignable } from '../../hooks';
import { useRecord } from '../../../record-provider';
import { SchemaSettings } from '../../../schema-settings';
import { useDesignable } from '../../hooks';
import { useIsBlockInPage } from './hooks/useIsBlockInPage';
const FixedBlockContext = React.createContext<{
setFixedBlock: (value: string | false) => void;
@ -70,10 +71,10 @@ export const FixedBlockDesignerItem = () => {
const { t } = useTranslation();
const fieldSchema = useFieldSchema();
const { dn } = useDesignable();
const record = useRecord();
const { inFixedBlock } = useFixedBlock();
const { isBlockInPage } = useIsBlockInPage();
if (Object.keys(record).length || !inFixedBlock) {
if (!isBlockInPage() || !inFixedBlock) {
return null;
}
return (

View File

@ -0,0 +1,15 @@
import { useCallback } from 'react';
import { useActionContext } from '../../action';
/**
*
*/
export const useIsBlockInPage = () => {
const { visible } = useActionContext();
const isBlockInPage = useCallback(() => {
return !visible;
}, [visible]);
return { isBlockInPage };
};