Skip to content

Commit

Permalink
fix(igxDropDown): fix toggle directive's onOpening call, closes #984
Browse files Browse the repository at this point in the history
  • Loading branch information
wnvko committed May 15, 2018
1 parent 0e56f9d commit 2766561
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/directives/toggle/toggle.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
if (!this.collapsed) { return; }

const player = this.animationActivation();
player.onStart(() => {
this.collapsed = false;
});
player.onDone(() => {
player.destroy();
if (fireEvents) {
this.onOpened.emit();
}
});

this.collapsed = !this.collapsed;
if (fireEvents) {
this.onOpening.emit();
}
Expand All @@ -89,10 +91,8 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
if (this.collapsed) { return; }

const player = this.animationActivation();
player.onStart(() => {
});
player.onDone(() => {
this.collapsed = !this.collapsed;
this.collapsed = true;
// When using directive into component with OnPush it is necessary to
// trigger change detection again when close animation ends
// due to late updated @collapsed property.
Expand Down
2 changes: 1 addition & 1 deletion src/drop-down/drop-down.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="igx-drop-down">
<div class="igx-drop-down__list" igxToggle (onOpening)="onToggleOpening()" (onOpened)="onToggleOpened()" (onClosed)="onToggleClosed()">
<div class="igx-drop-down__list" igxToggle (onOpening)="onToggleOpening()" (onOpened)="onToggleOpened()" (onClosing)="onToggleClosing()" (onClosed)="onToggleClosed()">
<ng-container *ngIf="!toggleDirective.collapsed">
<ng-content></ng-content>
</ng-container>
Expand Down
5 changes: 5 additions & 0 deletions src/drop-down/drop-down.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ export class IgxDropDownComponent implements IToggleView, OnInit {
}

onToggleOpening() {
this.toggleDirective.collapsed = false;
this.cdr.detectChanges();
this.scrollToItem(this.selectedItem);
this.onOpening.emit();
Expand All @@ -301,6 +302,10 @@ export class IgxDropDownComponent implements IToggleView, OnInit {
this.onOpened.emit();
}

onToggleClosing() {
this.onClosing.emit();
}

onToggleClosed() {
if (this._focusedItem) {
this._focusedItem.isFocused = false;
Expand Down

0 comments on commit 2766561

Please sign in to comment.