@@ -62,7 +62,7 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
6262 , splitBarMargin : 8
6363
6464 /**
65- * @property {Object } focusRestoreEl - Set Focus back on the this Element
65+ * @property {Object } focusRestoreEl - Set Focus back on this Element
6666 */
6767 , focusRestoreEl : [ ]
6868
@@ -509,6 +509,7 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
509509 submenu . classList . remove ( 'active' ) ;
510510 } else {
511511 this . hideMenu ( ) ;
512+ var isClick = false ;
512513 submenu . classList . add ( 'active' ) ;
513514 setTimeout ( ( ) => {
514515 var firstFocusEl = submenu . querySelectorAll ( 'a' ) [ 0 ] ;
@@ -517,10 +518,16 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
517518 }
518519 firstFocusEl . focus ( ) ;
519520 } , 50 ) ;
521+ var menuItemClicked = ( e ) => {
522+ isClick = true ;
523+ window . removeEventListener ( 'click' , menuItemClicked ) ;
524+ } ;
520525 var focusRestore = ( e ) => {
521526 requestAnimationFrame ( ( ) => {
522527 if ( ! submenu . contains ( document . activeElement ) ) {
523- this . focusRestoreEl ?. focus ( ) ;
528+ if ( ! isClick ) {
529+ this . focusRestoreEl ?. focus ( ) ;
530+ }
524531 this . hideMenu ( ) ;
525532 window . removeEventListener ( 'focusout' , focusRestore ) ;
526533 }
@@ -533,6 +540,7 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
533540 window . removeEventListener ( 'keyup' , menuArrowKeysNavigation ) ;
534541 }
535542 } ;
543+ window . addEventListener ( 'click' , menuItemClicked ) ;
536544 window . addEventListener ( 'focusout' , focusRestore ) ;
537545 window . addEventListener ( 'keyup' , menuArrowKeysNavigation ) ;
538546 }
0 commit comments