@@ -107,7 +107,6 @@ export default {
107107 const menuProps = {
108108 props : {
109109 multiple,
110- defaultActiveFirst : defaultActiveFirstOption ,
111110 itemIcon : multiple ? menuItemSelectedIcon : null ,
112111 selectedKeys,
113112 prefixCls : `${ prefixCls } -menu` ,
@@ -131,11 +130,15 @@ export default {
131130 const activeKeyProps = { } ;
132131
133132 let clonedMenuItems = menuItems ;
133+ let defaultActiveFirst = defaultActiveFirstOption ;
134134 if ( selectedKeys . length || firstActiveValue ) {
135135 if ( props . visible && ! this . lastVisible ) {
136- activeKeyProps . activeKey =
137- selectedKeys [ 0 ] !== undefined ? selectedKeys [ 0 ] : firstActiveValue ;
136+ activeKeyProps . activeKey = selectedKeys [ 0 ] || firstActiveValue ; ;
138137 } else if ( ! visible ) {
138+ // Do not trigger auto active since we already have selectedKeys
139+ if ( selectedKeys [ 0 ] ) {
140+ defaultActiveFirst = false ;
141+ }
139142 activeKeyProps . activeKey = undefined ;
140143 }
141144 let foundFirst = false ;
@@ -180,7 +183,7 @@ export default {
180183 if ( inputValue !== this . lastInputValue && ( ! lastValue || lastValue !== backfillValue ) ) {
181184 activeKeyProps . activeKey = '' ;
182185 }
183- menuProps . props = { ...activeKeyProps , ...menuProps . props } ;
186+ menuProps . props = { ...activeKeyProps , ...menuProps . props , ... { defaultActiveFirst } } ;
184187 return < Menu { ...menuProps } > { clonedMenuItems } </ Menu > ;
185188 }
186189 return null ;
0 commit comments