fix: fix designer button does not appear (#2120)
* refactor: convert to optional chain expresion * fix: fix designer button does not appear
This commit is contained in:
parent
73f3929b4f
commit
ffcf9d2211
@ -217,11 +217,11 @@ const HeaderMenu = ({
|
|||||||
const s = schema.properties[info.key];
|
const s = schema.properties[info.key];
|
||||||
if (mode === 'mix') {
|
if (mode === 'mix') {
|
||||||
if (s['x-component'] !== 'Menu.SubMenu') {
|
if (s['x-component'] !== 'Menu.SubMenu') {
|
||||||
onSelect && onSelect(info);
|
onSelect?.(info);
|
||||||
} else {
|
} else {
|
||||||
const menuItemSchema = findMenuItem(s);
|
const menuItemSchema = findMenuItem(s);
|
||||||
if (!menuItemSchema) {
|
if (!menuItemSchema) {
|
||||||
return onSelect && onSelect(info);
|
return onSelect?.(info);
|
||||||
}
|
}
|
||||||
// TODO
|
// TODO
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@ -230,8 +230,7 @@ const HeaderMenu = ({
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}, 100);
|
}, 100);
|
||||||
onSelect &&
|
onSelect?.({
|
||||||
onSelect({
|
|
||||||
key: menuItemSchema.name,
|
key: menuItemSchema.name,
|
||||||
item: {
|
item: {
|
||||||
props: {
|
props: {
|
||||||
@ -241,7 +240,7 @@ const HeaderMenu = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
onSelect && onSelect(info);
|
onSelect?.(info);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
mode={mode === 'mix' ? 'horizontal' : mode}
|
mode={mode === 'mix' ? 'horizontal' : mode}
|
||||||
@ -315,7 +314,7 @@ const SideMenu = ({
|
|||||||
defaultOpenKeys={defaultOpenKeys}
|
defaultOpenKeys={defaultOpenKeys}
|
||||||
defaultSelectedKeys={defaultSelectedKeys}
|
defaultSelectedKeys={defaultSelectedKeys}
|
||||||
onSelect={(info) => {
|
onSelect={(info) => {
|
||||||
onSelect && onSelect(info);
|
onSelect?.(info);
|
||||||
}}
|
}}
|
||||||
className={sideMenuClass}
|
className={sideMenuClass}
|
||||||
items={items as MenuProps['items']}
|
items={items as MenuProps['items']}
|
||||||
@ -489,13 +488,13 @@ Menu.Item = observer(
|
|||||||
>
|
>
|
||||||
{field.title}
|
{field.title}
|
||||||
</span>
|
</span>
|
||||||
{Designer && <Designer />}
|
<Designer />
|
||||||
</SortableItem>
|
</SortableItem>
|
||||||
</FieldContext.Provider>
|
</FieldContext.Provider>
|
||||||
</SchemaContext.Provider>
|
</SchemaContext.Provider>
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}, [field.title, icon, schema]);
|
}, [field.title, icon, schema, Designer]);
|
||||||
|
|
||||||
if (!pushMenuItem) {
|
if (!pushMenuItem) {
|
||||||
error('Menu.Item must be wrapped by GetMenuItemsContext.Provider');
|
error('Menu.Item must be wrapped by GetMenuItemsContext.Provider');
|
||||||
@ -547,13 +546,13 @@ Menu.URL = observer(
|
|||||||
>
|
>
|
||||||
{field.title}
|
{field.title}
|
||||||
</span>
|
</span>
|
||||||
{Designer && <Designer />}
|
<Designer />
|
||||||
</SortableItem>
|
</SortableItem>
|
||||||
</FieldContext.Provider>
|
</FieldContext.Provider>
|
||||||
</SchemaContext.Provider>
|
</SchemaContext.Provider>
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}, [field.title, icon, props.href, schema]);
|
}, [field.title, icon, props.href, schema, Designer]);
|
||||||
|
|
||||||
pushMenuItem(item);
|
pushMenuItem(item);
|
||||||
return null;
|
return null;
|
||||||
@ -582,7 +581,7 @@ Menu.SubMenu = observer(
|
|||||||
<SortableItem className={subMenuDesignerCss} removeParentsIfNoChildren={false}>
|
<SortableItem className={subMenuDesignerCss} removeParentsIfNoChildren={false}>
|
||||||
<Icon type={icon} />
|
<Icon type={icon} />
|
||||||
{field.title}
|
{field.title}
|
||||||
{Designer && <Designer />}
|
<Designer />
|
||||||
</SortableItem>
|
</SortableItem>
|
||||||
</FieldContext.Provider>
|
</FieldContext.Provider>
|
||||||
</SchemaContext.Provider>
|
</SchemaContext.Provider>
|
||||||
@ -591,7 +590,7 @@ Menu.SubMenu = observer(
|
|||||||
return <RecursionField schema={schema} onlyRenderProperties />;
|
return <RecursionField schema={schema} onlyRenderProperties />;
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
}, [field.title, icon, schema, children]);
|
}, [field.title, icon, schema, children, Designer]);
|
||||||
|
|
||||||
if (!pushMenuItem) {
|
if (!pushMenuItem) {
|
||||||
error('Menu.SubMenu must be wrapped by GetMenuItemsContext.Provider');
|
error('Menu.SubMenu must be wrapped by GetMenuItemsContext.Provider');
|
||||||
|
Loading…
Reference in New Issue
Block a user