((props, ref) => {
- const { style, name = uid(), applyMenuStyle = true, className, items, icon, title, onClick, children } = props;
+ const {
+ style,
+ closeInitializerMenuWhenClick = true,
+ name = uid(),
+ applyMenuStyle = true,
+ className,
+ items,
+ icon,
+ title,
+ onClick,
+ children,
+ } = props;
const compile = useCompile();
const childrenItems = useSchemaInitializerMenuItems(items, name, onClick);
const { componentCls, hashId } = useSchemaInitializerStyles();
const { attribute } = useAriaAttributeOfMenuItem();
-
+ const { setVisible } = useSchemaInitializer();
const menuItems = useMemo(() => {
if (!(items && items.length > 0)) return undefined;
return [
@@ -47,6 +62,9 @@ export const SchemaInitializerItem = memo(
label: children || compile(title),
onClick: (info) => {
if (info.key !== name) return;
+ if (closeInitializerMenuWhenClick) {
+ setVisible?.(false);
+ }
onClick?.({ ...info, item: props });
},
icon: typeof icon === 'string' ? : icon,
@@ -58,12 +76,14 @@ export const SchemaInitializerItem = memo(
if (items && items.length > 0) {
return ;
}
-
return (
{
event.stopPropagation();
+ if (closeInitializerMenuWhenClick) {
+ setVisible?.(false);
+ }
onClick?.({ event, item: props });
}}
>
@@ -74,8 +94,10 @@ export const SchemaInitializerItem = memo(
>
{children || (
<>
- {icon && typeof icon === 'string' ? : icon}
- {compile(title)}
+ {typeof icon === 'string' ? : icon}
+
+ {compile(title)}
+
>
)}
diff --git a/packages/core/client/src/application/schema-initializer/components/SchemaInitializerSwitch.tsx b/packages/core/client/src/application/schema-initializer/components/SchemaInitializerSwitch.tsx
index 770844ca02451..3a5b519714ea6 100644
--- a/packages/core/client/src/application/schema-initializer/components/SchemaInitializerSwitch.tsx
+++ b/packages/core/client/src/application/schema-initializer/components/SchemaInitializerSwitch.tsx
@@ -22,7 +22,7 @@ export const SchemaInitializerSwitch: FC = (pr
const { title, checked, ...resets } = props;
const compile = useCompile();
return (
-
+
{compile(title)}
diff --git a/packages/core/client/src/application/schema-initializer/types.ts b/packages/core/client/src/application/schema-initializer/types.ts
index 2671940715554..4c6954f3e041c 100644
--- a/packages/core/client/src/application/schema-initializer/types.ts
+++ b/packages/core/client/src/application/schema-initializer/types.ts
@@ -32,7 +32,7 @@ type SchemaInitializerItemBuiltInType = T & {
export interface SchemaInitializerItemComponentType {
name: string;
- Component: ComponentType | string;
+ Component?: ComponentType | string;
sort?: number;
componentProps?: Omit;
useComponentProps?: () => Omit;
diff --git a/packages/core/client/src/modules/blocks/data-blocks/details-multi/__e2e__/schemaInitializer.test.ts b/packages/core/client/src/modules/blocks/data-blocks/details-multi/__e2e__/schemaInitializer.test.ts
index 9a251e9dec9ea..93a59a41ec007 100644
--- a/packages/core/client/src/modules/blocks/data-blocks/details-multi/__e2e__/schemaInitializer.test.ts
+++ b/packages/core/client/src/modules/blocks/data-blocks/details-multi/__e2e__/schemaInitializer.test.ts
@@ -114,6 +114,7 @@ test.describe('configure actions', () => {
await page.getByLabel('schema-initializer-ActionBar-detailsWithPaging:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Edit' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-detailsWithPaging:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Delete' }).click();
await page.mouse.move(300, 0);
diff --git a/packages/core/client/src/modules/blocks/data-blocks/details-multi/__e2e__/schemaSettings.test.ts b/packages/core/client/src/modules/blocks/data-blocks/details-multi/__e2e__/schemaSettings.test.ts
index 7a10aeea91756..8dfeba7b33d19 100644
--- a/packages/core/client/src/modules/blocks/data-blocks/details-multi/__e2e__/schemaSettings.test.ts
+++ b/packages/core/client/src/modules/blocks/data-blocks/details-multi/__e2e__/schemaSettings.test.ts
@@ -68,6 +68,7 @@ test.describe('actions schema settings', () => {
// 创建 Edit & Delete 两个按钮
await page.getByLabel('schema-initializer-ActionBar-detailsWithPaging:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Edit' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-detailsWithPaging:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Delete' }).click();
await page.mouse.move(0, 300);
diff --git a/packages/core/client/src/modules/blocks/data-blocks/grid-card/__e2e__/schemaInitializer.test.ts b/packages/core/client/src/modules/blocks/data-blocks/grid-card/__e2e__/schemaInitializer.test.ts
index ba92d21f74fd6..8790f8e366279 100644
--- a/packages/core/client/src/modules/blocks/data-blocks/grid-card/__e2e__/schemaInitializer.test.ts
+++ b/packages/core/client/src/modules/blocks/data-blocks/grid-card/__e2e__/schemaInitializer.test.ts
@@ -67,7 +67,9 @@ test.describe('configure global actions', () => {
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Filter' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-gridCard:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Add new' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-gridCard:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Refresh' }).click();
await page.mouse.move(300, 0);
@@ -95,7 +97,9 @@ test.describe('configure item actions', () => {
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureItemActions-general').first().hover();
await page.getByRole('menuitem', { name: 'View' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-gridCard:configureItemActions-general').first().hover();
await page.getByRole('menuitem', { name: 'Edit' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-gridCard:configureItemActions-general').first().hover();
await page.getByRole('menuitem', { name: 'Delete' }).click();
await page.mouse.move(300, 0);
@@ -121,6 +125,7 @@ test.describe('configure item actions', () => {
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureItemActions-general').first().hover();
await page.getByRole('menuitem', { name: 'Popup' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-gridCard:configureItemActions-general').first().hover();
await page.getByRole('menuitem', { name: 'Update record' }).click();
await page.mouse.move(300, 0);
diff --git a/packages/core/client/src/modules/blocks/data-blocks/list/__e2e__/schemaInitializer.test.ts b/packages/core/client/src/modules/blocks/data-blocks/list/__e2e__/schemaInitializer.test.ts
index 10bf64fe4a447..07858f5e61692 100644
--- a/packages/core/client/src/modules/blocks/data-blocks/list/__e2e__/schemaInitializer.test.ts
+++ b/packages/core/client/src/modules/blocks/data-blocks/list/__e2e__/schemaInitializer.test.ts
@@ -64,7 +64,9 @@ test.describe('configure global actions', () => {
await page.getByLabel('schema-initializer-ActionBar-list:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Filter' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-list:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Add new' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-list:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Refresh' }).click();
await page.mouse.move(300, 0);
@@ -92,7 +94,9 @@ test.describe('configure item actions', () => {
await page.getByLabel('schema-initializer-ActionBar-list:configureItemActions-general').first().hover();
await page.getByRole('menuitem', { name: 'View' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-list:configureItemActions-general').first().hover();
await page.getByRole('menuitem', { name: 'Edit' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-list:configureItemActions-general').first().hover();
await page.getByRole('menuitem', { name: 'Delete' }).click();
await page.mouse.move(300, 0);
@@ -118,6 +122,7 @@ test.describe('configure item actions', () => {
await page.getByLabel('schema-initializer-ActionBar-list:configureItemActions-general').first().hover();
await page.getByRole('menuitem', { name: 'Popup' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-list:configureItemActions-general').first().hover();
await page.getByRole('menuitem', { name: 'Update record' }).click();
await page.mouse.move(300, 0);
diff --git a/packages/core/client/src/modules/blocks/data-blocks/table-selector/__e2e__/schemaInitializer.test.ts b/packages/core/client/src/modules/blocks/data-blocks/table-selector/__e2e__/schemaInitializer.test.ts
index 5260a9772e1e8..90b133637743e 100644
--- a/packages/core/client/src/modules/blocks/data-blocks/table-selector/__e2e__/schemaInitializer.test.ts
+++ b/packages/core/client/src/modules/blocks/data-blocks/table-selector/__e2e__/schemaInitializer.test.ts
@@ -38,8 +38,11 @@ test.describe('configure actions', () => {
// add buttons
await page.getByLabel('schema-initializer-ActionBar-table:configureActions-users').hover();
await page.getByRole('menuitem', { name: 'Filter' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-table:configureActions-users').hover();
await page.getByRole('menuitem', { name: 'Add new' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-table:configureActions-users').hover();
await page.getByRole('menuitem', { name: 'Delete' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-table:configureActions-users').hover();
await page.getByRole('menuitem', { name: 'Refresh' }).click();
await page.mouse.move(300, 0);
diff --git a/packages/core/client/src/modules/blocks/data-blocks/table/TableActionColumnInitializers.tsx b/packages/core/client/src/modules/blocks/data-blocks/table/TableActionColumnInitializers.tsx
index 6b22aa4e35255..609960c427b8f 100644
--- a/packages/core/client/src/modules/blocks/data-blocks/table/TableActionColumnInitializers.tsx
+++ b/packages/core/client/src/modules/blocks/data-blocks/table/TableActionColumnInitializers.tsx
@@ -32,12 +32,10 @@ export const Resizable = () => {
title={t('Column width')}
component={React.forwardRef((props, ref) => {
const { children, onClick, ...others } = props;
- const { setVisible } = useSchemaInitializer();
return (
{
- setVisible(false);
onClick(event);
}}
{...others}
diff --git a/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaInitializer.test.ts b/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaInitializer.test.ts
index d611e1365e5c5..a1be4dbb8ba82 100644
--- a/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaInitializer.test.ts
+++ b/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaInitializer.test.ts
@@ -138,7 +138,13 @@ test.describe('configure actions column', () => {
await page.getByText('Actions', { exact: true }).hover();
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-').hover();
await page.getByRole('menuitem', { name: 'View' }).click();
+
+ await page.getByText('Actions', { exact: true }).hover();
+ await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-').hover();
await page.getByRole('menuitem', { name: 'Edit' }).click();
+
+ await page.getByText('Actions', { exact: true }).hover();
+ await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-').hover();
await page.getByRole('menuitem', { name: 'Delete' }).click();
await page.getByRole('menuitem', { name: 'Duplicate' }).click();
@@ -163,9 +169,10 @@ test.describe('configure actions column', () => {
// add custom action ------------------------------------------------------------
await page.getByText('Actions', { exact: true }).hover();
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-').hover();
-
await page.getByRole('menuitem', { name: 'Popup' }).click();
- // 此时二级菜单,不应该关闭,可以继续点击?
+
+ await page.getByText('Actions', { exact: true }).hover();
+ await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-').hover();
await page.getByRole('menuitem', { name: 'Update record' }).click();
await page.mouse.move(300, 0);
diff --git a/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaInitializer1.test.ts b/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaInitializer1.test.ts
index c452e1632595a..45331cf1cdcea 100644
--- a/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaInitializer1.test.ts
+++ b/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaInitializer1.test.ts
@@ -119,8 +119,11 @@ test.describe('configure actions', () => {
// add buttons
await page.getByLabel('schema-initializer-ActionBar-table:configureActions-t_unp4scqamw9').hover();
await page.getByRole('menuitem', { name: 'Filter' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-table:configureActions-t_unp4scqamw9').hover();
await page.getByRole('menuitem', { name: 'Add new' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-table:configureActions-t_unp4scqamw9').hover();
await page.getByRole('menuitem', { name: 'Delete' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-table:configureActions-t_unp4scqamw9').hover();
await page.getByRole('menuitem', { name: 'Refresh' }).click();
await page.mouse.move(300, 0);
diff --git a/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaSettings.test.ts b/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaSettings.test.ts
index 55fe31b954d16..2e6e266bb7981 100644
--- a/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaSettings.test.ts
+++ b/packages/core/client/src/modules/blocks/data-blocks/table/__e2e__/schemaSettings.test.ts
@@ -37,6 +37,9 @@ const addSomeCustomActions = async (page: Page) => {
await page.getByRole('button', { name: 'Actions', exact: true }).hover();
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-general').hover();
await page.getByRole('menuitem', { name: 'Popup' }).click();
+
+ await page.getByRole('button', { name: 'Actions', exact: true }).hover();
+ await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-general').hover();
await page.getByRole('menuitem', { name: 'Update record' }).click();
};
diff --git a/packages/core/client/src/modules/popup/__e2e__/schemaInitializer1.test.ts b/packages/core/client/src/modules/popup/__e2e__/schemaInitializer1.test.ts
index 044b3e1afdca4..e8bd9d95946f7 100644
--- a/packages/core/client/src/modules/popup/__e2e__/schemaInitializer1.test.ts
+++ b/packages/core/client/src/modules/popup/__e2e__/schemaInitializer1.test.ts
@@ -34,6 +34,7 @@ test.describe('where to open a popup and what can be added to it', () => {
// add blocks
await page.getByLabel('schema-initializer-Grid-popup:addNew:addBlock-general').hover();
await page.getByText('Markdown').click();
+ await page.getByLabel('schema-initializer-Grid-popup:addNew:addBlock-general').hover();
await page.getByText('Form').hover();
await page.getByRole('menuitem', { name: 'Current collection' }).click();
@@ -146,6 +147,7 @@ test.describe('where to open a popup and what can be added to it', () => {
// add blocks
await page.getByLabel('schema-initializer-Grid-popup:bulkEdit:addBlock-general').hover();
await page.getByText('Form').click();
+ await page.getByLabel('schema-initializer-Grid-popup:bulkEdit:addBlock-general').hover();
await page.getByRole('menuitem', { name: 'Markdown' }).click();
await page.mouse.move(300, 0);
diff --git a/packages/core/client/src/schema-component/antd/action/Action.tsx b/packages/core/client/src/schema-component/antd/action/Action.tsx
index 41c8cd490fc3d..270161229fbb4 100644
--- a/packages/core/client/src/schema-component/antd/action/Action.tsx
+++ b/packages/core/client/src/schema-component/antd/action/Action.tsx
@@ -127,8 +127,8 @@ export const Action: ComposedAction = withDynamicSchemaProps(
}, [field, linkageRules, localVariables, variables]);
const handleButtonClick = useCallback(
- (e: React.MouseEvent) => {
- if (isPortalInBody(e.target as Element)) {
+ (e: React.MouseEvent, checkPortal = true) => {
+ if (checkPortal && isPortalInBody(e.target as Element)) {
return;
}
e.preventDefault();
@@ -186,7 +186,7 @@ export const Action: ComposedAction = withDynamicSchemaProps(
{...others}
onMouseEnter={handleMouseEnter}
loading={field?.data?.loading || loading}
- icon={icon ? : null}
+ icon={typeof icon === 'string' ? : icon}
disabled={disabled}
style={buttonStyle}
onClick={handleButtonClick}
diff --git a/packages/core/client/src/schema-initializer/items/DataBlockInitializer.tsx b/packages/core/client/src/schema-initializer/items/DataBlockInitializer.tsx
index e0fc35efcc2b5..9cd2854b0fb08 100644
--- a/packages/core/client/src/schema-initializer/items/DataBlockInitializer.tsx
+++ b/packages/core/client/src/schema-initializer/items/DataBlockInitializer.tsx
@@ -348,9 +348,10 @@ export const DataBlockInitializer: FC = (props) => {
onCreateBlockSchema({ item, fromOthersInPopup });
}
}
+
setVisible(false);
},
- [getTemplateSchemaByMode, insert, onCreateBlockSchema, propsOnClick, setVisible, templateWrap],
+ [getTemplateSchemaByMode, insert, setVisible, onCreateBlockSchema, propsOnClick, templateWrap],
);
const items =
itemsFromProps ||
diff --git a/packages/plugins/@nocobase/plugin-calendar/src/client/schema-initializer/initializers/CalendarFormActionInitializers.tsx b/packages/plugins/@nocobase/plugin-calendar/src/client/schema-initializer/initializers/CalendarFormActionInitializers.tsx
index 7a2dac6278f0f..48e1ff9998ac7 100644
--- a/packages/plugins/@nocobase/plugin-calendar/src/client/schema-initializer/initializers/CalendarFormActionInitializers.tsx
+++ b/packages/plugins/@nocobase/plugin-calendar/src/client/schema-initializer/initializers/CalendarFormActionInitializers.tsx
@@ -65,7 +65,7 @@ export const CalendarFormActionInitializers = new SchemaInitializer({
'x-component': 'Action',
'x-decorator': 'ACLActionProvider',
},
- visible: function useVisible() {
+ useVisible: function useVisible() {
const collection = useCollection_deprecated();
return (collection.template !== 'view' || collection?.writableView) && collection.template !== 'sql';
},
diff --git a/packages/plugins/@nocobase/plugin-gantt/src/client/__e2e__/schemaInitailizer.test.ts b/packages/plugins/@nocobase/plugin-gantt/src/client/__e2e__/schemaInitailizer.test.ts
index 412d2f3dfe8c1..e23dd9766230f 100644
--- a/packages/plugins/@nocobase/plugin-gantt/src/client/__e2e__/schemaInitailizer.test.ts
+++ b/packages/plugins/@nocobase/plugin-gantt/src/client/__e2e__/schemaInitailizer.test.ts
@@ -86,10 +86,15 @@ test.describe('configure actions', () => {
await mockPage(oneEmptyGantt).goto();
await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Filter' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Add new' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Delete' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Refresh' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Bulk update' }).click();
+ await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
await page.getByRole('menuitem', { name: 'Bulk edit' }).click();
await expect(page.getByLabel('action-Filter.Action-Filter-filter-general-table')).toBeVisible();
await expect(page.getByLabel('action-Action-Add new-create-general-table')).toBeVisible();
diff --git a/packages/plugins/@nocobase/plugin-workflow-manual/src/client/instruction/forms/custom.tsx b/packages/plugins/@nocobase/plugin-workflow-manual/src/client/instruction/forms/custom.tsx
index 3bef2c15afed3..44d43f1c71585 100644
--- a/packages/plugins/@nocobase/plugin-workflow-manual/src/client/instruction/forms/custom.tsx
+++ b/packages/plugins/@nocobase/plugin-workflow-manual/src/client/instruction/forms/custom.tsx
@@ -382,7 +382,7 @@ export const addCustomFormField = new CompatibleSchemaInitializer(
function CustomFormFieldInitializer() {
const itemConfig = useSchemaInitializerItem();
- const { insert, setVisible } = useSchemaInitializer();
+ const { insert } = useSchemaInitializer();
const { onAddField, setCallback } = useContext(AddCustomFormFieldButtonContext);
const { getInterface } = useCollectionManager_deprecated();
@@ -394,7 +394,6 @@ function CustomFormFieldInitializer() {
onClick={() => {
setCallback(() => insert);
onAddField(interfaceOptions);
- setVisible(false);
}}
{...itemConfig}
/>