@@ -378,23 +378,28 @@ export const InteractionsMixin = (superClass) =>
378378 this . _setExpanded ( button , true ) ;
379379 } ) ;
380380
381- if ( options . focusLast ) {
382- this . __onceOpened ( ( ) => this . _focusLastItem ( ) ) ;
383- }
381+ this . style . pointerEvents = 'auto' ;
384382
385- if ( options . keepFocus ) {
386- this . __onceOpened ( ( ) => {
387- this . _focusButton ( this . _expandedButton ) ;
388- } ) ;
389- }
383+ overlay . addEventListener (
384+ 'vaadin-overlay-open' ,
385+ ( ) => {
386+ if ( options . focusLast ) {
387+ this . _focusLastItem ( ) ;
388+ }
390389
391- this . __onceOpened ( ( ) => {
392- // Do not focus item when open not from keyboard
393- if ( event . type !== 'keydown' ) {
394- subMenu . $ . overlay . $ . overlay . focus ( ) ;
395- }
396- overlay . _updatePosition ( ) ;
397- } ) ;
390+ if ( options . keepFocus ) {
391+ this . _focusButton ( this . _expandedButton ) ;
392+ }
393+
394+ // Do not focus item when open not from keyboard
395+ if ( event . type !== 'keydown' ) {
396+ overlay . $ . overlay . focus ( ) ;
397+ }
398+
399+ overlay . _updatePosition ( ) ;
400+ } ,
401+ { once : true } ,
402+ ) ;
398403 }
399404
400405 /** @private */
@@ -412,17 +417,6 @@ export const InteractionsMixin = (superClass) =>
412417 }
413418 }
414419
415- /** @private */
416- __onceOpened ( cb ) {
417- this . style . pointerEvents = 'auto' ;
418- const overlay = this . _subMenu . $ . overlay ;
419- const listener = ( ) => {
420- cb ( ) ;
421- overlay . removeEventListener ( 'vaadin-overlay-open' , listener ) ;
422- } ;
423- overlay . addEventListener ( 'vaadin-overlay-open' , listener ) ;
424- }
425-
426420 /** @private */
427421 __onItemSelected ( e ) {
428422 e . stopPropagation ( ) ;
0 commit comments