diff --git a/packages/core/client/src/schema-component/antd/page/Page.tsx b/packages/core/client/src/schema-component/antd/page/Page.tsx index 6ed61b3a0c..36ecbadd4d 100644 --- a/packages/core/client/src/schema-component/antd/page/Page.tsx +++ b/packages/core/client/src/schema-component/antd/page/Page.tsx @@ -21,7 +21,6 @@ import { useTranslation } from 'react-i18next'; import { NavigateFunction, Outlet, useOutletContext } from 'react-router-dom'; import { FormDialog } from '..'; import { antTableCell } from '../../../acl/style'; -import { useRequest } from '../../../api-client'; import { CurrentTabUidContext, useCurrentSearchParams, @@ -392,25 +391,12 @@ const NocoBasePageHeader = React.memo(({ activeKey, className }: { activeKey: st const hidePageTitle = fieldSchema['x-component-props']?.hidePageTitle; useEffect(() => { - if (fieldSchema.title) { - const title = t(fieldSchema.title); + const title = t(fieldSchema.title) || t(currentRoute?.title); + if (title) { setDocumentTitle(title); setPageTitle(title); } - }, [fieldSchema.title, pageTitle, setDocumentTitle, t]); - - useRequest( - { - url: `/uiSchemas:getParentJsonSchema/${fieldSchema['x-uid']}`, - }, - { - ready: !hidePageTitle && !fieldSchema.title, - onSuccess(data) { - setPageTitle(data.data.title); - setDocumentTitle(data.data.title); - }, - }, - ); + }, [fieldSchema.title, pageTitle, setDocumentTitle, t, currentRoute?.title]); return ( <> diff --git a/packages/core/client/src/schema-component/antd/page/__tests__/page.test.tsx b/packages/core/client/src/schema-component/antd/page/__tests__/page.test.tsx index 814b327639..01654a8784 100644 --- a/packages/core/client/src/schema-component/antd/page/__tests__/page.test.tsx +++ b/packages/core/client/src/schema-component/antd/page/__tests__/page.test.tsx @@ -46,28 +46,6 @@ describe('Page', () => { expect(screen.queryByText('Test Title')).not.toBeInTheDocument(); }); - test('should request remote schema when no title', async () => { - await renderAppOptions({ - schema: { - type: 'void', - 'x-uid': 'test', - 'x-component': Page, - 'x-decorator': DocumentTitleProvider, - }, - apis: { - '/uiSchemas:getParentJsonSchema/test': { - data: { - title: 'remote title', - }, - }, - }, - }); - - await waitFor(() => { - expect(screen.getByText('remote title')).toBeInTheDocument(); - }); - }); - // TODO: This works normally in the actual page, but the test fails here test.skip('add tab', async () => { await renderAppOptions({