@@ -4,10 +4,12 @@ import SubMenu from './SubMenu';
44import BaseMixin from '../_util/BaseMixin' ;
55import { getWidth , setStyle , menuAllProps } from './util' ;
66import { cloneElement } from '../_util/vnode' ;
7- import { getPropsData , getAllProps , getSlot , findDOMNode } from '../_util/props-util' ;
7+ import { getAllProps , getSlot , findDOMNode } from '../_util/props-util' ;
88
99const MENUITEM_OVERFLOWED_CLASSNAME = 'menuitem-overflowed' ;
1010const FLOAT_PRECISION_ADJUST = 0.5 ;
11+ const MENUITEM_OVERFLOWED_UNI_KEY = 'MENUITEM_OVERFLOWED_UNI_KEY' ;
12+ const MENUITEM_OVERFLOWED_UNI_KEYS = [ MENUITEM_OVERFLOWED_UNI_KEY ] ;
1113
1214const DOMWrap = {
1315 name : 'DOMWrap' ,
@@ -136,6 +138,7 @@ const DOMWrap = {
136138 class : `${ prefixCls } -overflowed-submenu` ,
137139 key,
138140 style,
141+ isOverflowedSubMenu : true ,
139142 } ;
140143 return < SubMenu { ...subMenuProps } > { overflowedItems } </ SubMenu > ;
141144 } ,
@@ -227,7 +230,8 @@ const DOMWrap = {
227230 const className = this . $attrs . class || '' ;
228231 return ( children || [ ] ) . reduce ( ( acc , childNode , index ) => {
229232 let item = childNode ;
230- const eventKey = getPropsData ( childNode ) . eventKey ;
233+ const { extraProps = { } } = item . props || { } ;
234+ const { eventKey } = extraProps ;
231235 if ( this . mode === 'horizontal' ) {
232236 let overflowed = this . getOverflowedSubMenuItem ( eventKey , [ ] ) ;
233237 if (
@@ -239,21 +243,33 @@ const DOMWrap = {
239243 childNode ,
240244 // 这里修改 eventKey 是为了防止隐藏状态下还会触发 openkeys 事件
241245 {
242- style : { display : 'none' } ,
243- eventKey : `${ eventKey } -hidden` ,
244- class : MENUITEM_OVERFLOWED_CLASSNAME ,
246+ extraProps : {
247+ ...extraProps ,
248+ style : { display : 'none' } ,
249+ eventKey : `${ eventKey } -hidden` ,
250+ class : MENUITEM_OVERFLOWED_CLASSNAME ,
251+ parentUniKey : MENUITEM_OVERFLOWED_UNI_KEY ,
252+ parentUniKeys : MENUITEM_OVERFLOWED_UNI_KEYS ,
253+ } ,
245254 } ,
246255 ) ;
247256 }
248257 if ( index === lastVisibleIndex + 1 ) {
249258 this . overflowedItems = children . slice ( lastVisibleIndex + 1 ) . map ( c => {
259+ const { extraProps = { } } = c . props || { } ;
260+ const { eventKey } = extraProps ;
250261 return cloneElement (
251262 c ,
252263 // children[index].key will become '.$key' in clone by default,
253264 // we have to overwrite with the correct key explicitly
254265 {
255- key : getPropsData ( c ) . eventKey ,
256- mode : 'vertical-left' ,
266+ extraProps : {
267+ ...extraProps ,
268+ key : eventKey ,
269+ mode : 'vertical-left' ,
270+ parentUniKey : MENUITEM_OVERFLOWED_UNI_KEY ,
271+ parentUniKeys : MENUITEM_OVERFLOWED_UNI_KEYS ,
272+ } ,
257273 } ,
258274 ) ;
259275 } ) ;
0 commit comments