Skip to content

Commit

Permalink
Don't emit close on init
Browse files Browse the repository at this point in the history
  • Loading branch information
topaxi committed Mar 26, 2018
1 parent e915cdc commit ba7ccc9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.3.3

Don't emit close on initialization

## 0.3.2

Don't emit destroy on dropdown close
Expand Down
24 changes: 9 additions & 15 deletions angular-dropdown.directive.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Observable } from 'rxjs/Observable';
import {
BehaviorSubject
} from 'rxjs/BehaviorSubject';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/mapTo';

import {
Component,
Expand Down Expand Up @@ -106,16 +103,10 @@ export class AngularDropdownDirective implements OnChanges {
public horizontalPosition: HorizontalPosition = 'auto';

@Output('open')
onOpen: Observable<void> =
this.isOpen$
.filter(isOpen => isOpen === true)
.mapTo(void 0);
onOpen = new EventEmitter<void>();

@Output('close')
onClose: Observable<void> =
this.isOpen$
.filter(isOpen => isOpen === false)
.mapTo(void 0);
onClose = new EventEmitter<void>();

get triggerElement(): HTMLElement {
return this.control!.element.nativeElement;
Expand All @@ -136,10 +127,11 @@ export class AngularDropdownDirective implements OnChanges {
this.createDefaultWormholeOutlet();
}

ngOnChanges(changes: SimpleChanges): void {
if (changes['disabled'] &&
changes['disabled'].currentValue === true &&
changes['disabled'].previousValue !== true) {
ngOnChanges({ disabled }: SimpleChanges): void {
if (disabled &&
disabled.firstChange === false &&
disabled.currentValue === true &&
disabled.previousValue !== true) {
this.disable();
}
}
Expand All @@ -154,6 +146,7 @@ export class AngularDropdownDirective implements OnChanges {
}

this.isOpen$.next(true);
this.onOpen.emit();
}

close(skipFocus = false): void {
Expand All @@ -177,6 +170,7 @@ export class AngularDropdownDirective implements OnChanges {
previousHorizontalPosition: null
});
this.isOpen$.next(false);
this.onClose.emit();

if (!skipFocus) {
if (this.triggerElement instanceof HTMLElement &&
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-dropdown",
"version": "0.3.2",
"version": "0.3.3",
"description": "Simple angular dropdown component.",
"main": "angular-dropdown.module.ts",
"scripts": {
Expand Down
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
"experimentalDecorators": true,
"sourceMap": true,
"declaration": true,
"strict": true
"strict": true,
"lib": [
"dom",
"es5",
"es6"
]
},
"exclude": ["node_modules"]
}

0 comments on commit ba7ccc9

Please sign in to comment.