Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(select): lock dropdown position when scrolling #9789

Merged
merged 1 commit into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/cdk/overlay/overlay-directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
private _overlayRef: OverlayRef;
private _templatePortal: TemplatePortal;
private _hasBackdrop = false;
private _lockPosition = false;
private _backdropSubscription = Subscription.EMPTY;
private _offsetX: number = 0;
private _offsetY: number = 0;
Expand Down Expand Up @@ -155,6 +156,11 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
get hasBackdrop() { return this._hasBackdrop; }
set hasBackdrop(value: any) { this._hasBackdrop = coerceBooleanProperty(value); }

/** Whether or not the overlay should be locked when scrolling. */
@Input('cdkConnectedOverlayLockPosition')
get lockPosition() { return this._lockPosition; }
set lockPosition(value: any) { this._lockPosition = coerceBooleanProperty(value); }

/**
* @deprecated
* @deletion-target 6.0.0
Expand Down Expand Up @@ -296,6 +302,10 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
this._position.withPositions(this.positions);
}

if (changes['lockPosition']) {
this._position.withLockedPosition(this.lockPosition);
}

if (changes['origin'] || changes['_deprecatedOrigin']) {
this._position.setOrigin(this.origin.elementRef);

Expand Down Expand Up @@ -359,7 +369,8 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
const strategy = this._overlay.position()
.connectedTo(this.origin.elementRef, originPoint, overlayPoint)
.withOffsetX(this.offsetX)
.withOffsetY(this.offsetY);
.withOffsetY(this.offsetY)
.withLockedPosition(this.lockPosition);

for (let i = 1; i < this.positions.length; i++) {
strategy.withFallbackPosition(
Expand Down
1 change: 1 addition & 0 deletions src/lib/select/select.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ng-template
cdk-connected-overlay
hasBackdrop
cdkConnectedOverlayLockPosition
backdropClass="cdk-overlay-transparent-backdrop"
[scrollStrategy]="_scrollStrategy"
[origin]="origin"
Expand Down