Skip to content

Commit

Permalink
fix(module:dropdown): fix dropdown trigger events (#466)
Browse files Browse the repository at this point in the history
close #390
  • Loading branch information
vthinkxie committed Oct 21, 2017
1 parent 0eba3ae commit 6034f54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/components/dropdown/nz-dropdown-button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ export class NzDropDownButtonComponent extends NzDropDownComponent implements On
}
}
this.nzVisible = visible;
this.nzVisibleChange.emit(this.nzVisible);
this._changeDetector.markForCheck();
}

/** rewrite afterViewInit hook */
ngAfterViewInit() {
this._startSubscribe(this.nzVisibleChange.asObservable());
this._startSubscribe(this._visibleChange);
}
}
10 changes: 6 additions & 4 deletions src/components/dropdown/nz-dropdown.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { merge } from 'rxjs/observable/merge';
import { debounceTime } from 'rxjs/operator/debounceTime';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { Subscription } from 'rxjs/Subscription';
import { Observer } from 'rxjs/Observer'
import { NzMenuComponent } from '../menu/nz-menu.component';
Expand Down Expand Up @@ -42,7 +43,6 @@ export type NzPlacement = 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'topLe
[positions]="_positions"
[origin]="_nzOrigin"
(backdropClick)="_hide()"
(detach)="_hide()"
[minWidth]="_triggerWidth"
(positionChange)="_onPositionChange($event)"
[open]="nzVisible">
Expand Down Expand Up @@ -78,6 +78,7 @@ export class NzDropDownComponent implements OnInit, OnDestroy, AfterViewInit {
@Input() nzTrigger: 'click' | 'hover' = 'hover';
@Input() nzClickHide = true;
@Input() nzVisible = false;
@Output() _visibleChange = new Subject();
@Output() nzVisibleChange: EventEmitter<boolean> = new EventEmitter();

@Input()
Expand Down Expand Up @@ -110,11 +111,11 @@ export class NzDropDownComponent implements OnInit, OnDestroy, AfterViewInit {
}

_hide() {
this.nzVisibleChange.emit(false);
this._visibleChange.next(false);
}

_show() {
this.nzVisibleChange.emit(true);
this._visibleChange.next(true);
}

_onPositionChange(position) {
Expand All @@ -139,6 +140,7 @@ export class NzDropDownComponent implements OnInit, OnDestroy, AfterViewInit {
}
}
this.nzVisible = visible;
this.nzVisibleChange.emit(this.nzVisible);
this._changeDetector.markForCheck();
}

Expand Down Expand Up @@ -186,7 +188,7 @@ export class NzDropDownComponent implements OnInit, OnDestroy, AfterViewInit {
}
const observable$ = merge(
mouse$,
this.nzVisibleChange.asObservable()
this._visibleChange
);
this._startSubscribe(observable$);
}
Expand Down

0 comments on commit 6034f54

Please sign in to comment.