Skip to content

Commit

Permalink
fix(module:dropdown): fix dropdown break SSR (#5244)
Browse files Browse the repository at this point in the history
close #5186
  • Loading branch information
Yadong Xie authored May 11, 2020
1 parent e38333f commit 016cca1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/dropdown/dropdown.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
import { Overlay, OverlayRef } from '@angular/cdk/overlay';
import { Platform } from '@angular/cdk/platform';
import { TemplatePortal } from '@angular/cdk/portal';
import {
AfterViewInit,
Expand Down Expand Up @@ -70,7 +71,12 @@ export class NzDropDownDirective implements AfterViewInit, OnDestroy, OnChanges,
}
}

constructor(public elementRef: ElementRef, private overlay: Overlay, private viewContainerRef: ViewContainerRef) {}
constructor(
public elementRef: ElementRef,
private overlay: Overlay,
private viewContainerRef: ViewContainerRef,
private platform: Platform
) {}

ngOnInit(): void {
this.positionStrategy.positionChanges.pipe(takeUntil(this.destroy$)).subscribe(change => {
Expand Down Expand Up @@ -117,6 +123,7 @@ export class NzDropDownDirective implements AfterViewInit, OnDestroy, OnChanges,
map(([visible, sub]) => visible || sub),
auditTime(150),
distinctUntilChanged(),
filter(() => this.platform.isBrowser),
takeUntil(this.destroy$)
)
.subscribe((visible: boolean) => {
Expand Down
2 changes: 2 additions & 0 deletions components/dropdown/dropdown.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { OverlayModule } from '@angular/cdk/overlay';
import { PlatformModule } from '@angular/cdk/platform';

import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
Expand All @@ -33,6 +34,7 @@ import { NzDropDownDirective } from './dropdown.directive';
NzMenuModule,
NzIconModule,
NzNoAnimationModule,
PlatformModule,
NzOverlayModule,
NzContextMenuServiceModule,
NzOutletModule
Expand Down

0 comments on commit 016cca1

Please sign in to comment.