fix: fix the error of missing custom icon className

This commit is contained in:
wuxh 2023-01-06 17:48:03 +08:00
parent 2991e93b15
commit 71c79a3f75
No known key found for this signature in database
GPG Key ID: 464F03149513C20C

View File

@ -121,14 +121,23 @@ const InternalMenu = forwardRef<RcMenuRef, InternalMenuProps>((props, ref) => {
const menuClassName = classNames(`${prefixCls}-${theme}`, className);
// ====================== Expand Icon ========================
let mergedExpandIcon: MenuProps[`expandIcon`];
if (typeof expandIcon === 'function') {
mergedExpandIcon = expandIcon;
} else {
mergedExpandIcon = cloneElement(expandIcon || overrideObj.expandIcon, {
className: `${prefixCls}-submenu-expand-icon`,
});
}
const mergedExpandIcon: MenuProps[`expandIcon`] = (expandIconProps) => {
const nonUnderwriteExpandIcon: any =
typeof expandIcon === 'function'
? expandIcon(expandIconProps)
: expandIcon || overrideObj.expandIcon;
if (nonUnderwriteExpandIcon || nonUnderwriteExpandIcon === 0) {
return cloneElement(nonUnderwriteExpandIcon, {
className: classNames(
`${prefixCls}-submenu-expand-icon`,
nonUnderwriteExpandIcon?.props?.className,
),
});
}
return <i className={`${prefixCls}-submenu-arrow`} />;
};
// ======================== Context ==========================
const contextValue = React.useMemo<MenuContextProps>(