From 41c41128c27b4209e725a8c6ab73da5d6692330c Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Sat, 2 Nov 2024 13:48:54 +0800 Subject: [PATCH] fix(Action): make e2e tests pass --- .../src/schema-component/antd/action/context.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/action/context.tsx b/packages/core/client/src/schema-component/antd/action/context.tsx index 8f9e874d9a..673dbd6d25 100644 --- a/packages/core/client/src/schema-component/antd/action/context.tsx +++ b/packages/core/client/src/schema-component/antd/action/context.tsx @@ -11,7 +11,7 @@ import { useFieldSchema } from '@formily/react'; import _ from 'lodash'; import React, { createContext, useEffect, useMemo, useRef, useState } from 'react'; import { useParams } from 'react-router-dom'; -import { useDataBlockRequestGetter } from '../../../data-source'; +import { useDataBlockRequest } from '../../../data-source'; import { useCurrentPopupContext } from '../page/PagePopups'; import { getBlockService, storeBlockService } from '../page/pagePopupUtils'; import { ActionContextProps } from './types'; @@ -75,22 +75,21 @@ ActionContextProvider.displayName = 'ActionContextProvider'; const useBlockServiceInActionButton = () => { const { params } = useCurrentPopupContext(); - const fieldSchema = useFieldSchema(); const popupUidWithoutOpened = useFieldSchema()?.['x-uid']; - const { getDataBlockRequest } = useDataBlockRequestGetter(); + const service = useDataBlockRequest(); const currentPopupUid = params?.popupuid; // 把 service 存起来 useEffect(() => { if (popupUidWithoutOpened && currentPopupUid !== popupUidWithoutOpened) { - storeBlockService(popupUidWithoutOpened, { service: getDataBlockRequest() }); + storeBlockService(popupUidWithoutOpened, { service }); } - }, [popupUidWithoutOpened, getDataBlockRequest, currentPopupUid, fieldSchema]); + }, [currentPopupUid, popupUidWithoutOpened, service]); // 关闭弹窗时,获取到对应的 service if (currentPopupUid === popupUidWithoutOpened) { - return getBlockService(currentPopupUid)?.service || getDataBlockRequest(); + return getBlockService(currentPopupUid)?.service || service; } - return getDataBlockRequest(); + return service; };