@@ -264,6 +264,7 @@ export class MatTooltip implements OnDestroy {
264
264
const overlayRef = this . _createOverlay ( ) ;
265
265
266
266
this . _detach ( ) ;
267
+ overlayRef . setDirection ( this . _dir ? this . _dir . value : 'ltr' ) ;
267
268
this . _portal = this . _portal || new ComponentPortal ( TooltipComponent , this . _viewContainerRef ) ;
268
269
this . _tooltipInstance = overlayRef . attach ( this . _portal ) . instance ;
269
270
this . _tooltipInstance . afterHidden ( )
@@ -310,20 +311,12 @@ export class MatTooltip implements OnDestroy {
310
311
return this . _overlayRef ;
311
312
}
312
313
313
- const origin = this . _getOrigin ( ) ;
314
- const overlay = this . _getOverlayPosition ( ) ;
315
- const direction = this . _dir ? this . _dir . value : 'ltr' ;
316
-
317
314
// Create connected position strategy that listens for scroll events to reposition.
318
315
const strategy = this . _overlay . position ( )
319
316
. flexibleConnectedTo ( this . _elementRef )
320
317
. withTransformOriginOn ( '.mat-tooltip' )
321
318
. withFlexibleDimensions ( false )
322
- . withViewportMargin ( 8 )
323
- . withPositions ( [
324
- { ...origin . main , ...overlay . main } ,
325
- { ...origin . fallback , ...overlay . fallback }
326
- ] ) ;
319
+ . withViewportMargin ( 8 ) ;
327
320
328
321
const scrollableAncestors = this . _scrollDispatcher
329
322
. getAncestorScrollContainers ( this . _elementRef ) ;
@@ -341,12 +334,13 @@ export class MatTooltip implements OnDestroy {
341
334
} ) ;
342
335
343
336
this . _overlayRef = this . _overlay . create ( {
344
- direction,
345
337
positionStrategy : strategy ,
346
338
panelClass : TOOLTIP_PANEL_CLASS ,
347
339
scrollStrategy : this . _scrollStrategy ( )
348
340
} ) ;
349
341
342
+ this . _updatePosition ( ) ;
343
+
350
344
this . _overlayRef . detachments ( )
351
345
. pipe ( takeUntil ( this . _destroyed ) )
352
346
. subscribe ( ( ) => this . _detach ( ) ) ;
@@ -370,11 +364,10 @@ export class MatTooltip implements OnDestroy {
370
364
const origin = this . _getOrigin ( ) ;
371
365
const overlay = this . _getOverlayPosition ( ) ;
372
366
373
- position
374
- . withPositions ( [
375
- { ...origin . main , ...overlay . main } ,
376
- { ...origin . fallback , ...overlay . fallback }
377
- ] ) ;
367
+ position . withPositions ( [
368
+ { ...origin . main , ...overlay . main } ,
369
+ { ...origin . fallback , ...overlay . fallback }
370
+ ] ) ;
378
371
}
379
372
380
373
/**
0 commit comments