Skip to content

Commit f7db0bd

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 ebbf97e commit f7db0bd

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
@@ -339,17 +339,16 @@ export class MatTooltip implements OnDestroy {
339339
return this._overlayRef;
340340
}
341341

342+
const scrollableAncestors =
343+
this._scrollDispatcher.getAncestorScrollContainers(this._elementRef);
344+
342345
// Create connected position strategy that listens for scroll events to reposition.
343346
const strategy = this._overlay.position()
344-
.flexibleConnectedTo(this._elementRef)
345-
.withTransformOriginOn('.mat-tooltip')
346-
.withFlexibleDimensions(false)
347-
.withViewportMargin(8);
348-
349-
const scrollableAncestors = this._scrollDispatcher
350-
.getAncestorScrollContainers(this._elementRef);
351-
352-
strategy.withScrollableContainers(scrollableAncestors);
347+
.flexibleConnectedTo(this._elementRef)
348+
.withTransformOriginOn('.mat-tooltip')
349+
.withFlexibleDimensions(false)
350+
.withViewportMargin(8)
351+
.withScrollableContainers(scrollableAncestors);
353352

354353
strategy.positionChanges.pipe(takeUntil(this._destroyed)).subscribe(change => {
355354
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
@@ -122,7 +122,7 @@ export declare class FlexibleConnectedPositionStrategy implements PositionStrate
122122
withLockedPosition(isLocked?: boolean): this;
123123
withPositions(positions: ConnectedPosition[]): this;
124124
withPush(canPush?: boolean): this;
125-
withScrollableContainers(scrollables: CdkScrollable[]): void;
125+
withScrollableContainers(scrollables: CdkScrollable[]): this;
126126
withTransformOriginOn(selector: string): this;
127127
withViewportMargin(margin: number): this;
128128
}

0 commit comments

Comments
 (0)