diff --git a/components/dropdown/dropdown.directive.ts b/components/dropdown/dropdown.directive.ts index 3997c43246..8a8e9fff67 100644 --- a/components/dropdown/dropdown.directive.ts +++ b/components/dropdown/dropdown.directive.ts @@ -23,6 +23,7 @@ export class Dropdown implements OnInit, OnDestroy { @Output() public isOpenChange:EventEmitter = new EventEmitter(); @HostBinding('class.dropdown') private addClass = true; + private _isOpen:boolean; // index of selected element public selectedOption:number; diff --git a/components/dropdown/dropdown.service.ts b/components/dropdown/dropdown.service.ts index dea10952b2..133580a4a4 100644 --- a/components/dropdown/dropdown.service.ts +++ b/components/dropdown/dropdown.service.ts @@ -7,18 +7,17 @@ import {Dropdown} from './dropdown.directive'; export class DropdownService { private openScope:Dropdown; - private dropdownScope:Dropdown; private closeDropdownBind:EventListener = this.closeDropdown.bind(this); private keybindFilterBind:EventListener = this.keybindFilter.bind(this); public open(dropdownScope:Dropdown) { if (!this.openScope) { - window.document.addEventListener('click', this.closeDropdownBind); + window.document.addEventListener('click', this.closeDropdownBind, true); window.document.addEventListener('keydown', this.keybindFilterBind); } - if (this.openScope && this.openScope !== this.dropdownScope) { + if (this.openScope && this.openScope !== dropdownScope) { this.openScope.isOpen = false; } @@ -31,7 +30,7 @@ export class DropdownService { } this.openScope = null; - window.document.removeEventListener('click', this.closeDropdownBind); + window.document.removeEventListener('click', this.closeDropdownBind, true); window.document.removeEventListener('keydown', this.keybindFilterBind); }