File tree Expand file tree Collapse file tree 2 files changed +39
-8
lines changed Expand file tree Collapse file tree 2 files changed +39
-8
lines changed Original file line number Diff line number Diff line change @@ -74,14 +74,14 @@ export default function useKeyRecords() {
74
74
75
75
const isSubPathKey = useCallback (
76
76
( pathKeys : string [ ] , eventKey : string ) =>
77
- pathKeys . some ( pathKey => {
78
- const pathKeyList = getKeyPath ( pathKey , true ) ;
79
-
80
- return pathKeyList . includes ( eventKey ) ;
81
- } ) ,
77
+ pathKeys
78
+ . filter ( item => item !== undefined )
79
+ . some ( pathKey => {
80
+ const pathKeyList = getKeyPath ( pathKey , true ) ;
81
+ return pathKeyList . includes ( eventKey ) ;
82
+ } ) ,
82
83
[ getKeyPath ] ,
83
84
) ;
84
-
85
85
const getKeys = ( ) => {
86
86
const keys = [ ...key2pathRef . current . keys ( ) ] ;
87
87
Original file line number Diff line number Diff line change @@ -150,6 +150,31 @@ describe('SubMenu', () => {
150
150
expect ( childText ) . toEqual ( 'submenu' ) ;
151
151
} ) ;
152
152
153
+ it ( `The submenu item with key '' must not persistently remain active` , ( ) => {
154
+ const { container } = render (
155
+ < Menu
156
+ mode = "horizontal"
157
+ items = { [
158
+ {
159
+ label : '菜单一' ,
160
+ key : '1' ,
161
+ } ,
162
+ {
163
+ label : '菜单二' ,
164
+ key : '' ,
165
+ children : [
166
+ {
167
+ label : 'Navigation One1' ,
168
+ key : 'mail1' ,
169
+ } ,
170
+ ] ,
171
+ } ,
172
+ ] }
173
+ /> ,
174
+ ) ;
175
+ expect ( container . querySelector ( '.rc-menu-submenu-active' ) ) . toBeFalsy ( ) ;
176
+ } ) ;
177
+
153
178
describe ( 'openSubMenuOnMouseEnter and closeSubMenuOnMouseLeave are true' , ( ) => {
154
179
it ( 'toggles when mouse enter and leave' , ( ) => {
155
180
const { container } = render (
@@ -496,8 +521,14 @@ describe('SubMenu', () => {
496
521
497
522
fireEvent . mouseEnter ( container . querySelector ( '.rc-menu-submenu-title' ) ) ;
498
523
runAllTimer ( ) ;
499
- expect ( ( container . querySelector ( '.rc-menu-submenu-popup' ) as HTMLElement ) . style . zIndex ) . toEqual ( '100' ) ;
500
- expect ( ( container . querySelector ( '.rc-menu-submenu-popup' ) as HTMLElement ) . style . width ) . toEqual ( '150px' ) ;
524
+ expect (
525
+ ( container . querySelector ( '.rc-menu-submenu-popup' ) as HTMLElement ) . style
526
+ . zIndex ,
527
+ ) . toEqual ( '100' ) ;
528
+ expect (
529
+ ( container . querySelector ( '.rc-menu-submenu-popup' ) as HTMLElement ) . style
530
+ . width ,
531
+ ) . toEqual ( '150px' ) ;
501
532
} ) ;
502
533
} ) ;
503
534
/* eslint-enable */
You can’t perform that action at this time.
0 commit comments