From eb49b8fec0b52fe8a84eaed1e89a1afbe99bd71e Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Thu, 26 Sep 2024 10:21:04 +0800 Subject: [PATCH] fix(embed): fix issue with unable to open popup in kanban (#5326) --- .../src/schema-component/antd/page/index.ts | 4 ++-- .../plugin-kanban/src/client/Kanban.Card.tsx | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/page/index.ts b/packages/core/client/src/schema-component/antd/page/index.ts index 7460d583f2..6f6b803703 100644 --- a/packages/core/client/src/schema-component/antd/page/index.ts +++ b/packages/core/client/src/schema-component/antd/page/index.ts @@ -13,6 +13,6 @@ export * from './FixedBlockDesignerItem'; export * from './Page'; export * from './Page.Settings'; export { PagePopups } from './PagePopups'; -export { storePopupContext, getStoredPopupContext } from './pagePopupUtils'; +export { getStoredPopupContext, storePopupContext } from './pagePopupUtils'; export * from './PageTab.Settings'; -export { PopupSettingsProvider } from './PopupSettingsProvider'; +export { PopupSettingsProvider, usePopupSettings } from './PopupSettingsProvider'; diff --git a/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.Card.tsx b/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.Card.tsx index 8f22c7672c..fd4b8c94ae 100644 --- a/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.Card.tsx +++ b/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.Card.tsx @@ -17,12 +17,13 @@ import { PopupContextProvider, useCollection, useCollectionRecordData, + usePopupSettings, usePopupUtils, VariablePopupRecordProvider, } from '@nocobase/client'; import { Schema } from '@nocobase/utils'; import { Card } from 'antd'; -import React, { useCallback, useContext, useMemo } from 'react'; +import React, { useCallback, useContext, useMemo, useState } from 'react'; import { KanbanCardContext } from './context'; const cardCss = css` @@ -80,14 +81,20 @@ export const KanbanCard: any = observer( const { openPopup, getPopupSchemaFromSchema } = usePopupUtils(); const recordData = useCollectionRecordData(); const popupSchema = getPopupSchemaFromSchema(fieldSchema) || getPopupSchemaFromParent(fieldSchema); + const [visible, setVisible] = useState(false); + const { isPopupVisibleControlledByURL } = usePopupSettings(); const handleCardClick = useCallback( (e: React.MouseEvent) => { const targetElement = e.target as Element; // 将事件目标转换为Element类型 const currentTargetElement = e.currentTarget as Element; if (currentTargetElement.contains(targetElement)) { - openPopup({ - popupUidUsedInURL: popupSchema?.['x-uid'], - }); + if (!isPopupVisibleControlledByURL()) { + setVisible(true); + } else { + openPopup({ + popupUidUsedInURL: popupSchema?.['x-uid'], + }); + } e.stopPropagation(); } else { e.stopPropagation(); @@ -136,7 +143,7 @@ export const KanbanCard: any = observer( - +