fix: disappearing of fixed-block option (#2914)
This commit is contained in:
parent
bbe7eed314
commit
b8bc32f421
@ -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 { 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 { useTranslation } from 'react-i18next';
|
||||||
import { useDesignable } from '../../hooks';
|
|
||||||
import { useRecord } from '../../../record-provider';
|
import { useRecord } from '../../../record-provider';
|
||||||
|
import { SchemaSettings } from '../../../schema-settings';
|
||||||
|
import { useDesignable } from '../../hooks';
|
||||||
|
import { useIsBlockInPage } from './hooks/useIsBlockInPage';
|
||||||
|
|
||||||
const FixedBlockContext = React.createContext<{
|
const FixedBlockContext = React.createContext<{
|
||||||
setFixedBlock: (value: string | false) => void;
|
setFixedBlock: (value: string | false) => void;
|
||||||
@ -70,10 +71,10 @@ export const FixedBlockDesignerItem = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const { dn } = useDesignable();
|
const { dn } = useDesignable();
|
||||||
const record = useRecord();
|
|
||||||
const { inFixedBlock } = useFixedBlock();
|
const { inFixedBlock } = useFixedBlock();
|
||||||
|
const { isBlockInPage } = useIsBlockInPage();
|
||||||
|
|
||||||
if (Object.keys(record).length || !inFixedBlock) {
|
if (!isBlockInPage() || !inFixedBlock) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
@ -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 };
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user