Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
fix(autocomplete): Removes FlexibleConnectedPositionStrategy and make…
Browse files Browse the repository at this point in the history
…s _viewportRuler, _platform and _overlayContainer mandatory.

BREAKING CHANGE: Use DtFlexibleConnectedPositionStrategy instead.
  • Loading branch information
rowa-audil authored and ffriedl89 committed May 12, 2020
1 parent 98d1bac commit ed57594
Showing 1 changed file with 11 additions and 27 deletions.
38 changes: 11 additions & 27 deletions libs/barista-components/autocomplete/src/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
PositionStrategy,
ViewportRuler,
OverlayContainer,
FlexibleConnectedPositionStrategy,
} from '@angular/cdk/overlay';
import { DOCUMENT } from '@angular/common';
import {
Expand Down Expand Up @@ -237,11 +236,8 @@ export class DtAutocompleteTrigger<T>

/**
* Strategy that is used to position the panel.
* @breaking-change Switch to only use DtFlexibleConnectedPositionStrategy with 7.0.0
*/
private _positionStrategy:
| FlexibleConnectedPositionStrategy
| DtFlexibleConnectedPositionStrategy;
private _positionStrategy: DtFlexibleConnectedPositionStrategy;

/** Stream of keyboard events that can close the panel. */
private readonly _closeKeyEventStream = new Subject<void>();
Expand All @@ -263,15 +259,12 @@ export class DtAutocompleteTrigger<T>
private _changeDetectorRef: ChangeDetectorRef,
private _viewportResizer: DtViewportResizer,
private _zone: NgZone,
private _viewportRuler: ViewportRuler,
private _platform: Platform,
private _overlayContainer: OverlayContainer,
@Optional() @Host() private _formField?: DtFormField<string>,
// tslint:disable-next-line:no-any
@Optional() @Inject(DOCUMENT) private _document?: any,
/** @breaking-change 7.0.0 Make the _viewportRuler non optional. */
@Optional() private _viewportRuler?: ViewportRuler,
/** @breaking-change 7.0.0 Make the _platform non optional. */
@Optional() private _platform?: Platform,
/** @breaking-change 7.0.0 Make the _overlayContainer non optional. */
@Optional() private _overlayContainer?: OverlayContainer,
@Optional()
@Inject(DT_UI_TEST_CONFIG)
private _config?: DtUiTestConfiguration,
Expand Down Expand Up @@ -521,22 +514,13 @@ export class DtAutocompleteTrigger<T>
}

private _getOverlayPosition(): PositionStrategy {
/**
* @breaking-change Switch to only use the DtFlexibleConnectedPositionStrategy
* with 7.0.0
*/
const originalPositionStrategy =
this._viewportRuler && this._platform && this._overlayContainer
? new DtFlexibleConnectedPositionStrategy(
this._getConnectedElement(),
this._viewportRuler,
this._document,
this._platform,
this._overlayContainer,
)
: this._overlay
.position()
.flexibleConnectedTo(this._getConnectedElement());
const originalPositionStrategy = new DtFlexibleConnectedPositionStrategy(
this._getConnectedElement(),
this._viewportRuler,
this._document,
this._platform,
this._overlayContainer,
);

this._positionStrategy = originalPositionStrategy
.withFlexibleDimensions(false)
Expand Down

0 comments on commit ed57594

Please sign in to comment.