Skip to content

Commit 25e67e6

Browse files
crisbetojelbourn
authored andcommitted
refactor(overlay): inconsistent return type for FlexibleConnectedPositionStrategy.withScrollableContainers (#15610)
Fixes `FlexibleConnectedPositionStrategy.withScrollableContainers` returning `void`, whereas all other `with*` public methods are returning `this`. Fixes #15607.
1 parent 80538ef commit 25e67e6

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/cdk/overlay/position/flexible-connected-position-strategy.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,15 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
304304
this._applyPosition(fallback!.position, fallback!.originPoint);
305305
}
306306

307-
detach() {
307+
detach(): void {
308308
this._clearPanelClasses();
309309
this._lastPosition = null;
310310
this._previousPushAmount = null;
311311
this._resizeSubscription.unsubscribe();
312312
}
313313

314314
/** Cleanup after the element gets destroyed. */
315-
dispose() {
315+
dispose(): void {
316316
if (this._isDisposed) {
317317
return;
318318
}
@@ -369,8 +369,9 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
369369
* on reposition we can evaluate if it or the overlay has been clipped or outside view. Every
370370
* Scrollable must be an ancestor element of the strategy's origin element.
371371
*/
372-
withScrollableContainers(scrollables: CdkScrollable[]) {
372+
withScrollableContainers(scrollables: CdkScrollable[]): this {
373373
this.scrollables = scrollables;
374+
return this;
374375
}
375376

376377
/**

src/lib/tooltip/tooltip.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,17 +348,16 @@ export class MatTooltip implements OnDestroy, OnInit {
348348
return this._overlayRef;
349349
}
350350

351+
const scrollableAncestors =
352+
this._scrollDispatcher.getAncestorScrollContainers(this._elementRef);
353+
351354
// Create connected position strategy that listens for scroll events to reposition.
352355
const strategy = this._overlay.position()
353-
.flexibleConnectedTo(this._elementRef)
354-
.withTransformOriginOn('.mat-tooltip')
355-
.withFlexibleDimensions(false)
356-
.withViewportMargin(8);
357-
358-
const scrollableAncestors = this._scrollDispatcher
359-
.getAncestorScrollContainers(this._elementRef);
360-
361-
strategy.withScrollableContainers(scrollableAncestors);
356+
.flexibleConnectedTo(this._elementRef)
357+
.withTransformOriginOn('.mat-tooltip')
358+
.withFlexibleDimensions(false)
359+
.withViewportMargin(8)
360+
.withScrollableContainers(scrollableAncestors);
362361

363362
strategy.positionChanges.pipe(takeUntil(this._destroyed)).subscribe(change => {
364363
if (this._tooltipInstance) {

tools/public_api_guard/cdk/overlay.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export declare class FlexibleConnectedPositionStrategy implements PositionStrate
123123
withLockedPosition(isLocked?: boolean): this;
124124
withPositions(positions: ConnectedPosition[]): this;
125125
withPush(canPush?: boolean): this;
126-
withScrollableContainers(scrollables: CdkScrollable[]): void;
126+
withScrollableContainers(scrollables: CdkScrollable[]): this;
127127
withTransformOriginOn(selector: string): this;
128128
withViewportMargin(margin: number): this;
129129
}

0 commit comments

Comments
 (0)