From 4620a4293235c9adcd7e336659529b94df12f191 Mon Sep 17 00:00:00 2001 From: Semmy Date: Sat, 26 Mar 2022 00:21:12 +0800 Subject: [PATCH] fix: menu auto fold --- .../route-switch/antd/admin-layout/index.tsx | 2 +- .../src/schema-component/antd/menu/Menu.tsx | 107 ++++++++++-------- .../src/schema-settings/SchemaSettings.tsx | 10 +- 3 files changed, 61 insertions(+), 58 deletions(-) diff --git a/packages/client/src/route-switch/antd/admin-layout/index.tsx b/packages/client/src/route-switch/antd/admin-layout/index.tsx index e6e390dda..0d0f07961 100644 --- a/packages/client/src/route-switch/antd/admin-layout/index.tsx +++ b/packages/client/src/route-switch/antd/admin-layout/index.tsx @@ -13,7 +13,7 @@ import { RemoteSchemaTemplateManagerProvider, useDocumentTitle, useRoute, - useSystemSettings + useSystemSettings, } from '../../../'; const InternalAdminLayout = (props: any) => { diff --git a/packages/client/src/schema-component/antd/menu/Menu.tsx b/packages/client/src/schema-component/antd/menu/Menu.tsx index 69ea29dbc..2cc368279 100644 --- a/packages/client/src/schema-component/antd/menu/Menu.tsx +++ b/packages/client/src/schema-component/antd/menu/Menu.tsx @@ -192,59 +192,66 @@ export const Menu: ComposedMenu = observer((props) => { - .ant-menu-title-content > div { - .general-schema-designer { - display: block; - } - } - } - `} - onSelect={(info: any) => { - const s = schema.properties[info.key]; - if (mode === 'mix') { - setSideMenuSchema(s); - if (s['x-component'] !== 'Menu.SubMenu') { - onSelect && onSelect(info); - } else { - const menuItemSchema = findMenuItem(s); - if (!menuItemSchema) { - return; - } - // TODO - setLoading(true); - const keys = findKeysByUid(schema, menuItemSchema['x-uid']); - setDefaultSelectedKeys(keys); - setTimeout(() => { - setLoading(false); - }, 100); - onSelect && - onSelect({ - key: menuItemSchema.name, - item: { - props: { - schema: menuItemSchema, - }, - }, - }); - } - } else { - onSelect && onSelect(info); - } - }} - mode={mode === 'mix' ? 'horizontal' : mode} - defaultOpenKeys={defaultOpenKeys} - defaultSelectedKeys={defaultSelectedKeys} > - - {render({ style: { background: 'none', marginTop: 7, marginLeft: 8 } })} - + .ant-menu-title-content > div { + .general-schema-designer { + display: block; + } + } + } + `} + onSelect={(info: any) => { + const s = schema.properties[info.key]; + if (mode === 'mix') { + setSideMenuSchema(s); + if (s['x-component'] !== 'Menu.SubMenu') { + onSelect && onSelect(info); + } else { + const menuItemSchema = findMenuItem(s); + if (!menuItemSchema) { + return; + } + // TODO + setLoading(true); + const keys = findKeysByUid(schema, menuItemSchema['x-uid']); + setDefaultSelectedKeys(keys); + setTimeout(() => { + setLoading(false); + }, 100); + onSelect && + onSelect({ + key: menuItemSchema.name, + item: { + props: { + schema: menuItemSchema, + }, + }, + }); + } + } else { + onSelect && onSelect(info); + } + }} + mode={mode === 'mix' ? 'horizontal' : mode} + defaultOpenKeys={defaultOpenKeys} + defaultSelectedKeys={defaultSelectedKeys} + > + {render({ style: { background: 'none' } })} + {loading ? null : mode === 'mix' && diff --git a/packages/client/src/schema-settings/SchemaSettings.tsx b/packages/client/src/schema-settings/SchemaSettings.tsx index be8421128..c3c84ee61 100644 --- a/packages/client/src/schema-settings/SchemaSettings.tsx +++ b/packages/client/src/schema-settings/SchemaSettings.tsx @@ -13,7 +13,7 @@ import { SchemaComponentOptions, useActionContext, useAPIClient, - useCollection + useCollection, } from '..'; import { useSchemaTemplateManager } from '../schema-templates'; import { useBlockTemplateContext } from '../schema-templates/BlockTemplate'; @@ -182,11 +182,11 @@ SchemaSettings.Template = (props) => { }; SchemaSettings.Item = (props) => { - const { eventKey } = props; + let { eventKey } = props; return ( { info.domEvent.preventDefault(); @@ -200,10 +200,6 @@ SchemaSettings.Item = (props) => { ); }; -SchemaSettings.ItemGroup = (props) => { - return {props.children || props.title}; -}; - SchemaSettings.SubMenu = (props) => { return ; };