From a2da825b31ac94a97d780724f02270ac9aa281e6 Mon Sep 17 00:00:00 2001 From: jack zhang <1098626505@qq.com> Date: Sun, 4 Aug 2024 15:52:56 +0800 Subject: [PATCH] feat: mobile modal bug (#4976) * fix(T-4958): after closing the model, to reset the Form data * fix: bug --- .../src/schema-component/antd/action/Action.Modal.tsx | 8 ++++++-- .../plugin-acl/src/client/__e2e__/menu.test.ts | 10 +++++----- .../plugin-mobile-client/src/client/index.tsx | 2 +- .../plugin-mobile-client/src/locale/en-US.json | 2 +- .../plugin-mobile-client/src/locale/zh-CN.json | 2 +- packages/plugins/@nocobase/plugin-mobile/package.json | 4 ++-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/action/Action.Modal.tsx b/packages/core/client/src/schema-component/antd/action/Action.Modal.tsx index 6e798d5764..938bc4105b 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.Modal.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.Modal.tsx @@ -8,7 +8,7 @@ */ import { css } from '@emotion/css'; -import { observer, RecursionField, useField, useFieldSchema } from '@formily/react'; +import { observer, RecursionField, useField, useFieldSchema, useForm } from '@formily/react'; import { Modal, ModalProps } from 'antd'; import classNames from 'classnames'; import React, { useMemo } from 'react'; @@ -41,6 +41,7 @@ export const InternalActionModal: React.FC> = obse const { visible, setVisible, openSize = 'middle', modalProps } = useActionContext(); const actualWidth = width ?? openSizeWidthMap.get(openSize); const schema = useFieldSchema(); + const form = useForm(); const field = useField(); const { token } = useToken(); const footerSchema = schema.reduceProperties((buf, s) => { @@ -79,7 +80,10 @@ export const InternalActionModal: React.FC> = obse }} destroyOnClose open={visible} - onCancel={() => setVisible(false, true)} + onCancel={() => { + setVisible(false, true); + form.reset(); + }} className={classNames( others.className, modalProps?.className, diff --git a/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/menu.test.ts b/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/menu.test.ts index 51f2fe10a1..629027dd87 100644 --- a/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/menu.test.ts +++ b/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/menu.test.ts @@ -70,19 +70,19 @@ test('menu permission ', async ({ page, mockPage, mockRole, updateRole }) => { }); test('i18n should not fallbackNS', async ({ page }) => { - await page.goto('/admin'); + await page.goto('/admin/settings/system-settings'); // 创建 Users 页面 await page.getByTestId('schema-initializer-Menu-header').hover(); await page.getByRole('menuitem', { name: 'Page' }).click(); - await page.getByRole('textbox').click(); - await page.getByRole('textbox').fill('Users'); + await page.getByLabel('block-item-Input-Menu item').getByRole('textbox').click(); + await page.getByLabel('block-item-Input-Menu item').getByRole('textbox').fill('Users'); await page.getByRole('button', { name: 'OK' }).click(); await expect(page.getByLabel('Users')).toBeVisible(); await expect(page.getByLabel('用户')).not.toBeVisible(); // 添加中文选项 - await page.goto('/admin/settings/system-settings'); + await page.reload(); await page.getByTestId('select-multiple').click(); await page.getByRole('option', { name: '简体中文 (zh-CN)' }).click(); await page.getByLabel('action-Action-Submit').click(); @@ -92,7 +92,7 @@ test('i18n should not fallbackNS', async ({ page }) => { await page.getByText('LanguageEnglish').click(); await page.getByRole('option', { name: '简体中文' }).click(); - await page.goto('/admin/settings/system-settings'); + // await page.reload(); // 应该显示 Users 而非中文 “用户” await expect(page.getByLabel('Users')).toBeVisible(); diff --git a/packages/plugins/@nocobase/plugin-mobile-client/src/client/index.tsx b/packages/plugins/@nocobase/plugin-mobile-client/src/client/index.tsx index 3f20cd6934..d09163159f 100644 --- a/packages/plugins/@nocobase/plugin-mobile-client/src/client/index.tsx +++ b/packages/plugins/@nocobase/plugin-mobile-client/src/client/index.tsx @@ -29,7 +29,7 @@ export class PluginMobileClient extends Plugin { addSettings() { this.app.pluginSettingsManager.add(NAMESPACE, { - title: `{{t("Mobile Client-side", { ns: "${NAMESPACE}" })}}`, + title: `{{t("Mobile Client-side(Deprecated)", { ns: "${NAMESPACE}" })}}`, icon: 'MobileOutlined', Component: () => , }); diff --git a/packages/plugins/@nocobase/plugin-mobile-client/src/locale/en-US.json b/packages/plugins/@nocobase/plugin-mobile-client/src/locale/en-US.json index 117e24f99a..2142d1e5c5 100644 --- a/packages/plugins/@nocobase/plugin-mobile-client/src/locale/en-US.json +++ b/packages/plugins/@nocobase/plugin-mobile-client/src/locale/en-US.json @@ -1,5 +1,5 @@ { - "Mobile Client-side": "Mobile Client-side", + "Mobile Client-side(Deprecated)": "Mobile Client-side(Deprecated)", "Interface Configuration": "Interface Configuration", "App Configuration": "App Configuration", "Enable TabBar": "Enable TabBar", diff --git a/packages/plugins/@nocobase/plugin-mobile-client/src/locale/zh-CN.json b/packages/plugins/@nocobase/plugin-mobile-client/src/locale/zh-CN.json index becde917e6..bf49d544d9 100644 --- a/packages/plugins/@nocobase/plugin-mobile-client/src/locale/zh-CN.json +++ b/packages/plugins/@nocobase/plugin-mobile-client/src/locale/zh-CN.json @@ -1,5 +1,5 @@ { - "Mobile Client-side": "移动端", + "Mobile Client-side(Deprecated)": "移动端(已废弃)", "Interface Configuration": "界面配置", "App Configuration": "App配置", "Enable TabBar": "启用底部标签栏", diff --git a/packages/plugins/@nocobase/plugin-mobile/package.json b/packages/plugins/@nocobase/plugin-mobile/package.json index 6305a43ebb..1db505b2e1 100644 --- a/packages/plugins/@nocobase/plugin-mobile/package.json +++ b/packages/plugins/@nocobase/plugin-mobile/package.json @@ -5,8 +5,8 @@ "homepage": "https://docs.nocobase.com/handbook/mobile", "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/mobile", "license": "AGPL-3.0", - "displayName": "Mobile(Developing)", - "displayName.zh-CN": "移动端(开发中)", + "displayName": "Mobile", + "displayName.zh-CN": "移动端", "description": "Provides the ability to configure mobile pages.", "description.zh-CN": "提供移动端页面配置的能力。", "peerDependencies": {