From fe101ebf67f6943090583676fc1cb24a0ef786e3 Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Mon, 11 Nov 2024 21:30:09 +0800 Subject: [PATCH] fix(popup): fix the issue where popups cannot be opened in embedded pages --- .../src/schema-component/antd/action/Action.tsx | 2 +- .../src/schema-component/antd/table-v2/Table.tsx | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/action/Action.tsx b/packages/core/client/src/schema-component/antd/action/Action.tsx index 803ba57225..4a72569b97 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.tsx @@ -379,7 +379,7 @@ Action.Page = ActionPage; export default Action; // TODO: Plugin-related code should not exist in the core. It would be better to implement it by modifying the schema, but it would cause incompatibility. -function isBulkEditAction(fieldSchema) { +export function isBulkEditAction(fieldSchema) { return fieldSchema['x-action'] === 'customize:bulkEdit'; } diff --git a/packages/core/client/src/schema-component/antd/table-v2/Table.tsx b/packages/core/client/src/schema-component/antd/table-v2/Table.tsx index eda1a735f6..0dc9eccbf7 100644 --- a/packages/core/client/src/schema-component/antd/table-v2/Table.tsx +++ b/packages/core/client/src/schema-component/antd/table-v2/Table.tsx @@ -24,7 +24,7 @@ import _, { omit } from 'lodash'; import React, { useCallback, useContext, useMemo, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useInView } from 'react-intersection-observer'; -import { DndContext, useDesignable, useTableSize } from '../..'; +import { DndContext, isBulkEditAction, useDesignable, usePopupSettings, useTableSize } from '../..'; import { CollectionRecordProvider, RecordIndexProvider, @@ -103,6 +103,7 @@ const useTableColumns = (props: { showDel?: any; isSubTable?: boolean }, paginat }, []); const { current, pageSize } = paginationProps; const hasChangedColumns = useColumnsDeepMemoized(columnsSchemas); + const { isPopupVisibleControlledByURL } = usePopupSettings(); const schemaToolbarBigger = useMemo(() => { return css` @@ -164,7 +165,11 @@ const useTableColumns = (props: { showDel?: any; isSubTable?: boolean }, paginat schema={columnSchema} uiSchema={uiSchema} onlyRenderProperties - filterProperties={(schema) => schema['x-component'] !== 'Action.Container'} + filterProperties={(schema) => + isBulkEditAction(schema) || + !isPopupVisibleControlledByURL() || + schema['x-component'] !== 'Action.Container' + } /> ); @@ -188,7 +193,7 @@ const useTableColumns = (props: { showDel?: any; isSubTable?: boolean }, paginat // 这里不能把 columnsSchema 作为依赖,因为其每次都会变化,这里使用 hasChangedColumns 作为依赖 // eslint-disable-next-line react-hooks/exhaustive-deps - [hasChangedColumns, field.address, collection, schemaToolbarBigger, designable], + [hasChangedColumns, field.address, collection, schemaToolbarBigger, designable, isPopupVisibleControlledByURL], ); const tableColumns = useMemo(() => {