@@ -581,6 +581,14 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
581581 overlayStartY = pos . overlayY == 'top' ? 0 : - overlayRect . height ;
582582 }
583583
584+ // Adjust the overly position when it is placed inline relative to its parent.
585+ const insertOverlayAfter = this . _overlayRef . getConfig ( ) . insertOverlayAfter ;
586+ if ( insertOverlayAfter ) {
587+ const rect = insertOverlayAfter ! . nativeElement . parentElement . getBoundingClientRect ( ) ;
588+ overlayStartX -= rect . left ;
589+ overlayStartY -= rect . top ;
590+ }
591+
584592 // The (x, y) coordinates of the overlay.
585593 return {
586594 x : originPoint . x + overlayStartX ,
@@ -889,11 +897,26 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
889897 if ( this . _hasExactPosition ( ) ) {
890898 styles . top = styles . left = '0' ;
891899 styles . bottom = styles . right = styles . maxHeight = styles . maxWidth = '' ;
892- styles . width = styles . height = '100%' ;
900+
901+ if ( this . _overlayRef . getConfig ( ) . insertOverlayAfter ) {
902+ styles . width = coerceCssPixelValue ( boundingBoxRect . width ) ;
903+ styles . height = coerceCssPixelValue ( boundingBoxRect . height ) ;
904+ } else {
905+ // TODO(andreyd): can most likley remove this for common case
906+ styles . width = styles . height = '100%' ;
907+ }
893908 } else {
894909 const maxHeight = this . _overlayRef . getConfig ( ) . maxHeight ;
895910 const maxWidth = this . _overlayRef . getConfig ( ) . maxWidth ;
896911
912+ // Adjust the overly position when it is placed inline relative to its parent.
913+ const insertOverlayAfter = this . _overlayRef . getConfig ( ) . insertOverlayAfter ;
914+ if ( insertOverlayAfter ) {
915+ const rect = insertOverlayAfter ! . nativeElement . parentElement . getBoundingClientRect ( ) ;
916+ boundingBoxRect . left -= rect . left ;
917+ boundingBoxRect . top -= rect . top ;
918+ }
919+
897920 styles . height = coerceCssPixelValue ( boundingBoxRect . height ) ;
898921 styles . top = coerceCssPixelValue ( boundingBoxRect . top ) ;
899922 styles . bottom = coerceCssPixelValue ( boundingBoxRect . bottom ) ;
0 commit comments