@@ -19,11 +19,11 @@ import { warnItemProp } from '../utils/warnUtil';
1919import useDirectionStyle from '../hooks/useDirectionStyle' ;
2020import InlineSubMenuList from './InlineSubMenuList' ;
2121import {
22- PathConnectContext ,
22+ PathTrackerContext ,
2323 PathUserContext ,
24- useKeyPath ,
24+ useFullPath ,
2525 useMeasure ,
26- } from '../context/MeasureContext ' ;
26+ } from '../context/PathContext ' ;
2727import { useMenuId } from '../context/IdContext' ;
2828
2929export interface SubMenuProps {
@@ -122,8 +122,8 @@ const InternalSubMenu = (props: SubMenuProps) => {
122122 onActive,
123123 } = React . useContext ( MenuContext ) ;
124124
125- const { isSubPathKey, getKeyPath } = React . useContext ( PathUserContext ) ;
126- const keyPath = getKeyPath ( eventKey ) ;
125+ const { isSubPathKey } = React . useContext ( PathUserContext ) ;
126+ const connectedPath = useFullPath ( ) ;
127127
128128 const subMenuPrefixCls = `${ prefixCls } -submenu` ;
129129 const mergedDisabled = contextDisabled || disabled ;
@@ -189,7 +189,7 @@ const InternalSubMenu = (props: SubMenuProps) => {
189189 } , [ mode , active , activeKey , childrenActive , eventKey , isSubPathKey ] ) ;
190190
191191 // ========================== DirectionStyle ==========================
192- const directionStyle = useDirectionStyle ( keyPath . length ) ;
192+ const directionStyle = useDirectionStyle ( connectedPath . length ) ;
193193
194194 // =============================== Events ===============================
195195 // >>>> Title click
@@ -319,7 +319,7 @@ const InternalSubMenu = (props: SubMenuProps) => {
319319
320320 { /* Inline mode */ }
321321 { ! overflowDisabled && (
322- < InlineSubMenuList id = { popupId } open = { open } keyPath = { keyPath } >
322+ < InlineSubMenuList id = { popupId } open = { open } keyPath = { connectedPath } >
323323 { children }
324324 </ InlineSubMenuList >
325325 ) }
@@ -331,7 +331,7 @@ const InternalSubMenu = (props: SubMenuProps) => {
331331export default function SubMenu ( props : SubMenuProps ) {
332332 const { eventKey, children } = props ;
333333
334- const connectedKeyPath = useKeyPath ( eventKey ) ;
334+ const connectedKeyPath = useFullPath ( eventKey ) ;
335335 const childList : React . ReactElement [ ] = parseChildren (
336336 children ,
337337 connectedKeyPath ,
@@ -351,15 +351,18 @@ export default function SubMenu(props: SubMenuProps) {
351351 }
352352 } , [ connectedKeyPath ] ) ;
353353
354- if ( measure ) {
355- return (
356- < PathConnectContext . Provider value = { connectedKeyPath } >
357- { childList }
358- </ PathConnectContext . Provider >
359- ) ;
360- }
354+ let renderNode : React . ReactNode ;
361355
362356 // ======================== Render ========================
357+ if ( measure ) {
358+ renderNode = childList ;
359+ } else {
360+ renderNode = < InternalSubMenu { ...props } > { childList } </ InternalSubMenu > ;
361+ }
363362
364- return < InternalSubMenu { ...props } > { childList } </ InternalSubMenu > ;
363+ return (
364+ < PathTrackerContext . Provider value = { connectedKeyPath } >
365+ { renderNode }
366+ </ PathTrackerContext . Provider >
367+ ) ;
365368}
0 commit comments