@@ -51,7 +51,9 @@ class MenuButton extends Component {
5151 this . on ( this . menuButton_ , 'click' , this . handleClick ) ;
5252 this . on ( this . menuButton_ , 'focus' , this . handleFocus ) ;
5353 this . on ( this . menuButton_ , 'blur' , this . handleBlur ) ;
54-
54+ this . on ( this . menuButton_ , 'mouseenter' , ( ) => {
55+ this . menu . show ( ) ;
56+ } ) ;
5557 this . on ( 'keydown' , this . handleSubmenuKeyPress ) ;
5658 }
5759
@@ -221,14 +223,6 @@ class MenuButton extends Component {
221223 * @listens click
222224 */
223225 handleClick ( event ) {
224- // When you click the button it adds focus, which will show the menu.
225- // So we'll remove focus when the mouse leaves the button. Focus is needed
226- // for tab navigation.
227-
228- this . one ( this . menu . contentEl ( ) , 'mouseleave' , Fn . bind ( this , function ( e ) {
229- this . unpressButton ( ) ;
230- this . el_ . blur ( ) ;
231- } ) ) ;
232226 if ( this . buttonPressed_ ) {
233227 this . unpressButton ( ) ;
234228 } else {
@@ -299,8 +293,8 @@ class MenuButton extends Component {
299293 // Set focus back to the menu button's button
300294 this . menuButton_ . el_ . focus ( ) ;
301295 }
302- // Up (38) key or Down (40) key press the 'button'
303- } else if ( event . which === 38 || event . which === 40 ) {
296+ // Enter (13) or Up (38) key or Down (40) key press the 'button'
297+ } else if ( event . which === 13 || event . which === 38 || event . which === 40 ) {
304298 if ( ! this . buttonPressed_ ) {
305299 this . pressButton ( ) ;
306300 event . preventDefault ( ) ;
@@ -339,6 +333,7 @@ class MenuButton extends Component {
339333 pressButton ( ) {
340334 if ( this . enabled_ ) {
341335 this . buttonPressed_ = true ;
336+ this . menu . show ( ) ;
342337 this . menu . lockShowing ( ) ;
343338 this . menuButton_ . el_ . setAttribute ( 'aria-expanded' , 'true' ) ;
344339
@@ -360,6 +355,7 @@ class MenuButton extends Component {
360355 if ( this . enabled_ ) {
361356 this . buttonPressed_ = false ;
362357 this . menu . unlockShowing ( ) ;
358+ this . menu . hide ( ) ;
363359 this . menuButton_ . el_ . setAttribute ( 'aria-expanded' , 'false' ) ;
364360 }
365361 }
0 commit comments