fix: remove refreshComponent in Grid component (#6578)

* fix: remove refreshComponent in Grid component

* test: add e2e test for modal content persistence after reopening
This commit is contained in:
Zeke Zhang 2025-03-28 12:01:13 +08:00 committed by GitHub
parent 1b782c4f95
commit 9eaa47863d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 420 additions and 4 deletions

View File

@ -20,7 +20,6 @@ import { FilterBlockProvider } from '../../../filter-provider/FilterProvider';
import { import {
NocoBaseRecursionField, NocoBaseRecursionField,
RefreshComponentProvider, RefreshComponentProvider,
useRefreshComponent,
useRefreshFieldSchema, useRefreshFieldSchema,
} from '../../../formily/NocoBaseRecursionField'; } from '../../../formily/NocoBaseRecursionField';
import { DndContext, DndContextProps } from '../../common/dnd-context'; import { DndContext, DndContextProps } from '../../common/dnd-context';
@ -379,11 +378,9 @@ export const Grid: any = observer(
}, [fieldSchema, render, InitializerComponent, showDivider]); }, [fieldSchema, render, InitializerComponent, showDivider]);
const refreshFieldSchema = useRefreshFieldSchema(); const refreshFieldSchema = useRefreshFieldSchema();
const refreshComponent = useRefreshComponent();
const refresh = useCallback(() => { const refresh = useCallback(() => {
refreshFieldSchema?.(); refreshFieldSchema?.();
refreshComponent?.(); }, [refreshFieldSchema]);
}, [refreshComponent, refreshFieldSchema]);
return ( return (
<RefreshComponentProvider refresh={refresh}> <RefreshComponentProvider refresh={refresh}>

View File

@ -0,0 +1,34 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { expect, test } from '@nocobase/test/e2e';
import { afterConfiguringTheModalWhenReopeningItTheContentShouldPersist } from './utils';
test.describe('refresh', () => {
test('After configuring the modal, when reopening it, the content should persist', async ({ mockPage, page }) => {
await mockPage(afterConfiguringTheModalWhenReopeningItTheContentShouldPersist).goto();
// 1. 点击 Bulk edit 按钮,打开弹窗
await page.getByLabel('action-Action-Bulk edit-').click();
// 2. 新增一个表单区块
await page.getByLabel('schema-initializer-Grid-popup').hover();
await page.getByRole('menuitem', { name: 'form Form' }).click();
// 3. 新增一个名为 Nickname 的字段
await page.getByLabel('schema-initializer-Grid-bulkEditForm:configureFields-users').hover();
await page.getByRole('menuitem', { name: 'Nickname' }).click();
// 4. 关闭弹窗,然后再打开,刚才新增的字段应该还在
await page.getByLabel('drawer-Action.Container-users-Bulk edit-mask').click();
await page.getByLabel('action-Action-Bulk edit-').click();
await expect(page.getByLabel('block-item-BulkEditField-').getByText('Nickname')).toBeVisible();
await page.getByLabel('block-item-BulkEditField-').click();
});
});

View File

@ -1243,3 +1243,388 @@ export const theAddBlockButtonInDrawerShouldBeVisible = {
'x-index': 1, 'x-index': 1,
}, },
}; };
export const afterConfiguringTheModalWhenReopeningItTheContentShouldPersist = {
pageSchema: {
type: 'void',
'x-component': 'Page',
name: 'rjzvy4bmawn',
'x-uid': '1rs9caegbf2',
'x-async': false,
properties: {
tab: {
type: 'void',
'x-component': 'Grid',
'x-initializer': 'page:addBlock',
properties: {
bmsmf8futai: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': 'x84k7qs6jko',
'x-async': false,
'x-index': 4,
},
noe2oca30hc: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': 't7jxa830ps6',
'x-async': false,
'x-index': 5,
},
w2hnq7rau9p: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': '0fjjtg8z7ws',
'x-async': false,
'x-index': 7,
},
fcfs4oot86g: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': 'nklv7lonpgn',
'x-async': false,
'x-index': 8,
},
i22fydav355: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': 'fz4g6cr9jvr',
'x-async': false,
'x-index': 10,
},
row_6u7y7uccrvz: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-index': 12,
'x-uid': '7tzumo4nec7',
'x-async': false,
},
higfesvgj7g: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': '8hpa6qf3sez',
'x-async': false,
'x-index': 13,
},
'37myao9n0wc': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': 'uw1dp2qxd3y',
'x-async': false,
'x-index': 14,
},
uvfd76q4ye9: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': 'nc56fu33m42',
'x-async': false,
'x-index': 15,
},
miidizeqgot: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': 'jf4qarrcs0z',
'x-async': false,
'x-index': 16,
},
hxmr87i5imu: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': 'l3kdiqd9a7k',
'x-async': false,
'x-index': 17,
},
pa8dwdi4h5a: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': 'uz5wcet83qn',
'x-async': false,
'x-index': 18,
},
pno0a05tbnp: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': 'b4bakhhasp3',
'x-async': false,
'x-index': 19,
},
uj09g5xgnr1: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': 'qks035fnfl6',
'x-async': false,
'x-index': 20,
},
giobcwj316k: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
'x-uid': 'awwsb89nyso',
'x-async': false,
'x-index': 22,
},
oznewtbvuyw: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Row',
'x-app-version': '1.6.11',
properties: {
bwtax0bnnp3: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid.Col',
'x-app-version': '1.6.11',
properties: {
c0bypj7wg5q: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-decorator': 'TableBlockProvider',
'x-acl-action': 'users:list',
'x-use-decorator-props': 'useTableBlockDecoratorProps',
'x-decorator-props': {
collection: 'users',
dataSource: 'main',
action: 'list',
params: {
pageSize: 20,
},
rowKey: 'id',
showIndex: true,
dragSort: false,
},
'x-toolbar': 'BlockSchemaToolbar',
'x-settings': 'blockSettings:table',
'x-component': 'CardItem',
'x-filter-targets': [],
'x-app-version': '1.6.11',
properties: {
actions: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-initializer': 'table:configureActions',
'x-component': 'ActionBar',
'x-component-props': {
style: {
marginBottom: 'var(--nb-spacing)',
},
},
'x-app-version': '1.6.11',
properties: {
'1dlvhzr308c': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
title: '{{t("Bulk edit")}}',
'x-component': 'Action',
'x-action': 'customize:bulkEdit',
'x-action-settings': {
updateMode: 'selected',
},
'x-component-props': {
openMode: 'drawer',
icon: 'EditOutlined',
},
'x-align': 'right',
'x-decorator': 'BulkEditActionDecorator',
'x-toolbar': 'ActionSchemaToolbar',
'x-settings': 'actionSettings:bulkEdit',
'x-acl-action': 'update',
'x-acl-action-props': {
skipScopeCheck: true,
},
'x-app-version': '1.6.11',
properties: {
drawer: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
title: '{{t("Bulk edit")}}',
'x-component': 'Action.Container',
'x-component-props': {
className: 'nb-action-popup',
},
'x-app-version': '1.6.11',
properties: {
tabs: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'popup:addTab',
'x-initializer-props': {
gridInitializer: 'popup:bulkEdit:addBlock',
},
'x-app-version': '1.6.11',
properties: {
tab1: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
title: '{{t("Bulk edit")}}',
'x-component': 'Tabs.TabPane',
'x-designer': 'Tabs.Designer',
'x-component-props': {},
'x-app-version': '1.6.11',
properties: {
grid: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-component': 'Grid',
'x-initializer': 'popup:bulkEdit:addBlock',
'x-app-version': '1.6.11',
'x-uid': '5ejbu8v5ol8',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'gfheiqtl7f7',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'if2rcx1dy2n',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'cxyi8q6lm3n',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'vbvf13xq15t',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'amlzm32jhwg',
'x-async': false,
'x-index': 1,
},
f232o2ds23n: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'array',
'x-initializer': 'table:configureColumns',
'x-component': 'TableV2',
'x-use-component-props': 'useTableBlockProps',
'x-component-props': {
rowKey: 'id',
rowSelection: {
type: 'checkbox',
},
},
'x-app-version': '1.6.11',
properties: {
actions: {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
title: '{{ t("Actions") }}',
'x-action-column': 'actions',
'x-decorator': 'TableV2.Column.ActionBar',
'x-component': 'TableV2.Column',
'x-toolbar': 'TableColumnSchemaToolbar',
'x-initializer': 'table:configureItemActions',
'x-settings': 'fieldSettings:TableColumn',
'x-toolbar-props': {
initializer: 'table:configureItemActions',
},
'x-app-version': '1.6.11',
properties: {
'153lpq30p5f': {
_isJSONSchemaObject: true,
version: '2.0',
type: 'void',
'x-decorator': 'DndContext',
'x-component': 'Space',
'x-component-props': {
split: '|',
},
'x-app-version': '1.6.11',
'x-uid': '4mha1dmmyz9',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'afmceivuaf0',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'iu0xkmeuc5z',
'x-async': false,
'x-index': 2,
},
},
'x-uid': 'ylor106s9ok',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'rl50hidu14n',
'x-async': false,
'x-index': 1,
},
},
'x-uid': 'xxhug2yumqf',
'x-async': false,
'x-index': 23,
},
},
name: 'h63eibc46on',
'x-uid': 'u9g23o0ohgk',
'x-async': true,
'x-index': 1,
},
},
},
};