fix: menu modifications do not take effect in real-time (#5207)

* fix: menu modifications do not take effect in real-time

* fix: bug
This commit is contained in:
Katherine 2024-09-09 19:42:12 +08:00 committed by GitHub
parent db57b21e1a
commit 4399856eae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 6 deletions

View File

@ -272,7 +272,7 @@ export const MenuDesigner = () => {
title: field.title,
icon: field.componentProps.icon,
};
}, [field]);
}, [field.title, field.componentProps.icon]);
if (fieldSchema['x-component'] === 'Menu.URL') {
schema.properties['href'] = urlSchema;
schema.properties['params'] = paramsSchema;
@ -364,7 +364,6 @@ export const MenuDesigner = () => {
title: t('Delete menu item'),
};
}, [t]);
return (
<GeneralSchemaDesigner>
<SchemaSettingsModalItem

View File

@ -267,7 +267,6 @@ const HeaderMenu = ({
},
[schema, mode, onSelect, setLoading, setDefaultSelectedKeys],
);
return (
<>
<Component />
@ -530,14 +529,14 @@ Menu.Item = observer(
removeParentsIfNoChildren={false}
>
<Icon type={icon} />
<span style={menuItemTitleStyle}>{t(field.title)}</span>
<span style={menuItemTitleStyle}>{t(schema.title)}</span>
<Designer />
</SortableItem>
</FieldContext.Provider>
</SchemaContext.Provider>
),
};
}, [field.title, icon, schema, Designer]);
}, [schema.title, icon, schema, Designer]);
if (!pushMenuItem) {
error('Menu.Item must be wrapped by GetMenuItemsContext.Provider');

View File

@ -35,12 +35,12 @@ export const CustomRequestInitializer: React.FC<any> = (props) => {
const customRequestsResource = useCustomRequestsResource();
const itemConfig = useSchemaInitializerItem();
const { insert } = useSchemaInitializer();
const schema = getNewSchema();
return (
<SchemaInitializerItem
{...itemConfig}
onClick={async () => {
const schema = getNewSchema();
const s = merge(schema || {}, itemConfig.schema || {});
itemConfig?.schemaInitialize?.(s);
insert(s);