From ba7ccc9257c1f9c5e7275118173bdf5f1f603d85 Mon Sep 17 00:00:00 2001 From: Damian Senn Date: Mon, 26 Mar 2018 18:24:34 +0200 Subject: [PATCH] Don't emit close on init --- CHANGELOG.md | 4 ++++ angular-dropdown.directive.ts | 24 +++++++++--------------- package.json | 2 +- tsconfig.json | 7 ++++++- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9774bcb..64d238a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.3.3 + +Don't emit close on initialization + ## 0.3.2 Don't emit destroy on dropdown close diff --git a/angular-dropdown.directive.ts b/angular-dropdown.directive.ts index dc1cd3c..8b2c11d 100644 --- a/angular-dropdown.directive.ts +++ b/angular-dropdown.directive.ts @@ -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, @@ -106,16 +103,10 @@ export class AngularDropdownDirective implements OnChanges { public horizontalPosition: HorizontalPosition = 'auto'; @Output('open') - onOpen: Observable = - this.isOpen$ - .filter(isOpen => isOpen === true) - .mapTo(void 0); + onOpen = new EventEmitter(); @Output('close') - onClose: Observable = - this.isOpen$ - .filter(isOpen => isOpen === false) - .mapTo(void 0); + onClose = new EventEmitter(); get triggerElement(): HTMLElement { return this.control!.element.nativeElement; @@ -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(); } } @@ -154,6 +146,7 @@ export class AngularDropdownDirective implements OnChanges { } this.isOpen$.next(true); + this.onOpen.emit(); } close(skipFocus = false): void { @@ -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 && diff --git a/package.json b/package.json index 644e0d8..d2e177e 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/tsconfig.json b/tsconfig.json index 20d7bc5..1ddf0b3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,12 @@ "experimentalDecorators": true, "sourceMap": true, "declaration": true, - "strict": true + "strict": true, + "lib": [ + "dom", + "es5", + "es6" + ] }, "exclude": ["node_modules"] }