@@ -4,10 +4,12 @@ import SubMenu from './SubMenu';
4
4
import BaseMixin from '../_util/BaseMixin' ;
5
5
import { getWidth , setStyle , menuAllProps } from './util' ;
6
6
import { cloneElement } from '../_util/vnode' ;
7
- import { getPropsData , getAllProps , getSlot , findDOMNode } from '../_util/props-util' ;
7
+ import { getAllProps , getSlot , findDOMNode } from '../_util/props-util' ;
8
8
9
9
const MENUITEM_OVERFLOWED_CLASSNAME = 'menuitem-overflowed' ;
10
10
const 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 ] ;
11
13
12
14
const DOMWrap = {
13
15
name : 'DOMWrap' ,
@@ -136,6 +138,7 @@ const DOMWrap = {
136
138
class : `${ prefixCls } -overflowed-submenu` ,
137
139
key,
138
140
style,
141
+ isOverflowedSubMenu : true ,
139
142
} ;
140
143
return < SubMenu { ...subMenuProps } > { overflowedItems } </ SubMenu > ;
141
144
} ,
@@ -227,7 +230,8 @@ const DOMWrap = {
227
230
const className = this . $attrs . class || '' ;
228
231
return ( children || [ ] ) . reduce ( ( acc , childNode , index ) => {
229
232
let item = childNode ;
230
- const eventKey = getPropsData ( childNode ) . eventKey ;
233
+ const { extraProps = { } } = item . props || { } ;
234
+ const { eventKey } = extraProps ;
231
235
if ( this . mode === 'horizontal' ) {
232
236
let overflowed = this . getOverflowedSubMenuItem ( eventKey , [ ] ) ;
233
237
if (
@@ -239,21 +243,33 @@ const DOMWrap = {
239
243
childNode ,
240
244
// 这里修改 eventKey 是为了防止隐藏状态下还会触发 openkeys 事件
241
245
{
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
+ } ,
245
254
} ,
246
255
) ;
247
256
}
248
257
if ( index === lastVisibleIndex + 1 ) {
249
258
this . overflowedItems = children . slice ( lastVisibleIndex + 1 ) . map ( c => {
259
+ const { extraProps = { } } = c . props || { } ;
260
+ const { eventKey } = extraProps ;
250
261
return cloneElement (
251
262
c ,
252
263
// children[index].key will become '.$key' in clone by default,
253
264
// we have to overwrite with the correct key explicitly
254
265
{
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
+ } ,
257
273
} ,
258
274
) ;
259
275
} ) ;
0 commit comments