feat: mobile modal bug (#4976)

* fix(T-4958): after closing the model, to reset the Form data

* fix: bug
This commit is contained in:
jack zhang 2024-08-04 15:52:56 +08:00 committed by GitHub
parent 3a9b546f4f
commit a2da825b31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 16 additions and 12 deletions

View File

@ -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<ActionDrawerProps<ModalProps>> = 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<ActionDrawerProps<ModalProps>> = obse
}}
destroyOnClose
open={visible}
onCancel={() => setVisible(false, true)}
onCancel={() => {
setVisible(false, true);
form.reset();
}}
className={classNames(
others.className,
modalProps?.className,

View File

@ -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();

View File

@ -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: () => <Outlet />,
});

View File

@ -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",

View File

@ -1,5 +1,5 @@
{
"Mobile Client-side": "移动端",
"Mobile Client-side(Deprecated)": "移动端(已废弃)",
"Interface Configuration": "界面配置",
"App Configuration": "App配置",
"Enable TabBar": "启用底部标签栏",

View File

@ -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": {