@@ -36,18 +36,15 @@ export class OverflowMenuPane extends Dialog implements AfterViewInit {
3636
3737 onDialogInit ( ) {
3838 /**
39- * -20 shifts the menu up to compensate for the
40- * extra offset generated by the wrapper component.
41- *
4239 * 60 shifts the menu right to align the arrow.
4340 * (position service trys it's best to center everything,
4441 * so we need to add some compensation)
4542 */
4643 this . addGap [ "bottom" ] = pos => {
4744 if ( this . dialogConfig . flip ) {
48- return position . addOffset ( pos , - 20 , - 60 ) ;
45+ return position . addOffset ( pos , 0 , - 60 ) ;
4946 }
50- return position . addOffset ( pos , - 20 , 60 ) ;
47+ return position . addOffset ( pos , 0 , 60 ) ;
5148 } ;
5249
5350 if ( ! this . dialogConfig . menuLabel ) {
@@ -103,15 +100,19 @@ export class OverflowMenuPane extends Dialog implements AfterViewInit {
103100 }
104101
105102 ngAfterViewInit ( ) {
106- const focusElementList = this . listItems ( ) ;
107- focusElementList . forEach ( button => {
108- // Allows user to set tabindex to 0.
109- if ( button . getAttribute ( "tabindex" ) === null ) {
110- button . tabIndex = - 1 ;
111- }
103+ // wait for the menu to exist in the DOM before setting focus
104+ // TODO: work on a more elegant solution (afterDialogInit hook maybe?)
105+ setTimeout ( ( ) => {
106+ const focusElementList = this . listItems ( ) ;
107+ focusElementList . forEach ( button => {
108+ // Allows user to set tabindex to 0.
109+ if ( button . getAttribute ( "tabindex" ) === null ) {
110+ button . tabIndex = - 1 ;
111+ }
112+ } ) ;
113+ focusElementList [ 0 ] . tabIndex = 0 ;
114+ focusElementList [ 0 ] . focus ( ) ;
112115 } ) ;
113- focusElementList [ 0 ] . tabIndex = 0 ;
114- focusElementList [ 0 ] . focus ( ) ;
115116 super . ngAfterViewInit ( ) ;
116117 }
117118
0 commit comments