afc163
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
7 additions and
2 deletions
-
components/menu/MenuContext.tsx
-
components/menu/SubMenu.tsx
-
components/menu/menu.tsx
|
|
@ -1,4 +1,5 @@ |
|
|
|
import { createContext } from 'react'; |
|
|
|
import type { MenuProps } from 'rc-menu'; |
|
|
|
import type { DirectionType } from '../config-provider'; |
|
|
|
|
|
|
|
export type MenuTheme = 'light' | 'dark'; |
|
|
@ -7,6 +8,7 @@ export interface MenuContextProps { |
|
|
|
prefixCls: string; |
|
|
|
inlineCollapsed: boolean; |
|
|
|
direction?: DirectionType; |
|
|
|
mode?: MenuProps['mode']; |
|
|
|
theme?: MenuTheme; |
|
|
|
firstLevel: boolean; |
|
|
|
/** @internal Safe to remove */ |
|
|
|
|
|
@ -30,7 +30,7 @@ export interface SubMenuProps { |
|
|
|
function SubMenu(props: SubMenuProps) { |
|
|
|
const { popupClassName, icon, title, theme: customTheme } = props; |
|
|
|
const context = React.useContext(MenuContext); |
|
|
|
const { prefixCls, inlineCollapsed, theme: contextTheme } = context; |
|
|
|
const { prefixCls, inlineCollapsed, theme: contextTheme, mode } = context; |
|
|
|
|
|
|
|
const parentPath = useFullPath(); |
|
|
|
|
|
|
@ -68,10 +68,12 @@ function SubMenu(props: SubMenuProps) { |
|
|
|
[context], |
|
|
|
); |
|
|
|
|
|
|
|
const popupOffset = mode === 'horizontal' ? [0, 8] : [10, 0]; |
|
|
|
|
|
|
|
return ( |
|
|
|
<MenuContext.Provider value={contextValue}> |
|
|
|
<RcSubMenu |
|
|
|
popupOffset={[10, 0]} |
|
|
|
popupOffset={popupOffset} |
|
|
|
{...omit(props, ['icon'])} |
|
|
|
title={titleNode} |
|
|
|
popupClassName={classNames( |
|
|
|
|
|
@ -138,6 +138,7 @@ const InternalMenu = forwardRef<RcMenuRef, InternalMenuProps>((props, ref) => { |
|
|
|
direction, |
|
|
|
firstLevel: true, |
|
|
|
theme, |
|
|
|
mode: mergedMode, |
|
|
|
disableMenuItemTitleTooltip: _internalDisableMenuItemTitleTooltip, |
|
|
|
}), |
|
|
|
[prefixCls, mergedInlineCollapsed, direction, _internalDisableMenuItemTitleTooltip, theme], |
|
|
|