@@ -196,6 +196,7 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
196
196
}
197
197
198
198
const overlayRef = this . _createOverlay ( ) ;
199
+ this . _setPosition ( overlayRef . getConfig ( ) . positionStrategy as FlexibleConnectedPositionStrategy ) ;
199
200
overlayRef . attach ( this . _portal ) ;
200
201
201
202
if ( this . menu . lazyContent ) {
@@ -350,7 +351,9 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
350
351
*/
351
352
private _getOverlayConfig ( ) : OverlayConfig {
352
353
return new OverlayConfig ( {
353
- positionStrategy : this . _getPosition ( ) ,
354
+ positionStrategy : this . _overlay . position ( )
355
+ . flexibleConnectedTo ( this . _element )
356
+ . withTransformOriginOn ( '.mat-menu-panel' ) ,
354
357
hasBackdrop : this . menu . hasBackdrop == null ? ! this . triggersSubmenu ( ) : this . menu . hasBackdrop ,
355
358
backdropClass : this . menu . backdropClass || 'cdk-overlay-transparent-backdrop' ,
356
359
scrollStrategy : this . _scrollStrategy ( ) ,
@@ -375,11 +378,11 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
375
378
}
376
379
377
380
/**
378
- * This method builds the position strategy for the overlay, so the menu is properly connected
379
- * to the trigger.
380
- * @returns ConnectedPositionStrategy
381
+ * Sets the appropriate positions on a position strategy
382
+ * so the overlay connects with the trigger correctly .
383
+ * @param positionStrategy Strategy whose position to update.
381
384
*/
382
- private _getPosition ( ) : FlexibleConnectedPositionStrategy {
385
+ private _setPosition ( positionStrategy : FlexibleConnectedPositionStrategy ) {
383
386
let [ originX , originFallbackX ] : HorizontalConnectionPos [ ] =
384
387
this . menu . xPosition === 'before' ? [ 'end' , 'start' ] : [ 'start' , 'end' ] ;
385
388
@@ -401,27 +404,24 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
401
404
originFallbackY = overlayFallbackY === 'top' ? 'bottom' : 'top' ;
402
405
}
403
406
404
- return this . _overlay . position ( )
405
- . flexibleConnectedTo ( this . _element )
406
- . withTransformOriginOn ( '.mat-menu-panel' )
407
- . withPositions ( [
408
- { originX, originY, overlayX, overlayY, offsetY} ,
409
- { originX : originFallbackX , originY, overlayX : overlayFallbackX , overlayY, offsetY} ,
410
- {
411
- originX,
412
- originY : originFallbackY ,
413
- overlayX,
414
- overlayY : overlayFallbackY ,
415
- offsetY : - offsetY
416
- } ,
417
- {
418
- originX : originFallbackX ,
419
- originY : originFallbackY ,
420
- overlayX : overlayFallbackX ,
421
- overlayY : overlayFallbackY ,
422
- offsetY : - offsetY
423
- }
424
- ] ) ;
407
+ positionStrategy . withPositions ( [
408
+ { originX, originY, overlayX, overlayY, offsetY} ,
409
+ { originX : originFallbackX , originY, overlayX : overlayFallbackX , overlayY, offsetY} ,
410
+ {
411
+ originX,
412
+ originY : originFallbackY ,
413
+ overlayX,
414
+ overlayY : overlayFallbackY ,
415
+ offsetY : - offsetY
416
+ } ,
417
+ {
418
+ originX : originFallbackX ,
419
+ originY : originFallbackY ,
420
+ overlayX : overlayFallbackX ,
421
+ overlayY : overlayFallbackY ,
422
+ offsetY : - offsetY
423
+ }
424
+ ] ) ;
425
425
}
426
426
427
427
/** Cleans up the active subscriptions. */
0 commit comments