@@ -11,6 +11,7 @@ export default {
1111 name : 'DropdownMenu' ,
1212 mixins : [ BaseMixin ] ,
1313 props : {
14+ ariaId : PropTypes . string ,
1415 defaultActiveFirstOption : PropTypes . bool ,
1516 value : PropTypes . any ,
1617 dropdownMenuStyle : PropTypes . object ,
@@ -28,8 +29,10 @@ export default {
2829 menuItemSelectedIcon : PropTypes . any ,
2930 } ,
3031
31- beforeMount ( ) {
32+ created ( ) {
33+ this . rafInstance = { cancel : ( ) => null }
3234 this . lastInputValue = this . $props . inputValue
35+ this . lastVisible = false
3336 } ,
3437
3538 mounted ( ) {
@@ -101,6 +104,7 @@ export default {
101104 firstActiveValue,
102105 dropdownMenuStyle,
103106 backfillValue,
107+ visible,
104108 } = props
105109 const menuItemSelectedIcon = getComponentFromProp ( this , 'menuItemSelectedIcon' )
106110 const { menuDeselect, menuSelect, popupScroll } = this . $listeners
@@ -136,16 +140,16 @@ export default {
136140 if ( selectedKeys . length || firstActiveValue ) {
137141 if ( props . visible && ! this . lastVisible ) {
138142 activeKeyProps . activeKey = selectedKeys [ 0 ] !== undefined ? selectedKeys [ 0 ] : firstActiveValue
143+ } else if ( ! visible ) {
144+ activeKeyProps . activeKey = undefined
139145 }
140146 let foundFirst = false
141147 // set firstActiveItem via cloning menus
142148 // for scroll into view
143149 const clone = item => {
144150 if (
145151 ( ! foundFirst && selectedKeys . indexOf ( item . key ) !== - 1 ) ||
146- ( ! foundFirst &&
147- ! selectedKeys . length &&
148- firstActiveValue . indexOf ( item . key ) !== - 1 )
152+ ( ! foundFirst && ! selectedKeys . length && firstActiveValue . indexOf ( item . key ) !== - 1 )
149153 ) {
150154 foundFirst = true
151155 return cloneElement ( item , {
@@ -198,6 +202,8 @@ export default {
198202 overflow : 'auto' ,
199203 transform : 'translateZ(0)' ,
200204 } }
205+ id = { this . $props . ariaId }
206+ tabIndex = '-1'
201207 onFocus = { popupFocus }
202208 onMousedown = { preventDefaultEvent }
203209 onScroll = { popupScroll }
0 commit comments