Skip to content

Commit

Permalink
feat(dropdown): drop prevent event propogation from dropdown toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
valorkin committed Nov 3, 2017
1 parent 62fd267 commit 5cbe131
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
13 changes: 2 additions & 11 deletions src/dropdown/bs-dropdown-toggle.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ import { BsDropdownState } from './bs-dropdown.state';
}
})
export class BsDropdownToggleDirective implements OnDestroy {
/**
* Set it to false to let click event propagate.
*/
@Input() suppressClick: boolean = true;

@HostBinding('attr.disabled') isDisabled: boolean = null;

// @HostBinding('class.active')
Expand All @@ -45,12 +40,8 @@ export class BsDropdownToggleDirective implements OnDestroy {
);
}

@HostListener('click', ['$event'])
onClick(event: MouseEvent): void {
if (this.suppressClick) {
event.stopPropagation();
}

@HostListener('click', [])
onClick(): void {
if (this.isDisabled) {
return;
}
Expand Down
11 changes: 6 additions & 5 deletions src/dropdown/bs-dropdown.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ export class BsDropdownDirective implements OnInit, OnDestroy {
*/
@Input()
set autoClose(value: boolean) {
if (typeof value === 'boolean') {
this._state.autoClose = value;
}
this._state.autoClose = value;
}

get autoClose(): boolean {
Expand Down Expand Up @@ -135,6 +133,9 @@ export class BsDropdownDirective implements OnInit, OnDestroy {
private _cis: ComponentLoaderFactory,
private _config: BsDropdownConfig,
private _state: BsDropdownState) {
// set initial dropdown state from config
this._state.autoClose = this._config.autoClose;

// create dropdown component loader
this._dropdown = this._cis
.createLoader<BsDropdownContainerComponent>(
Expand All @@ -148,8 +149,6 @@ export class BsDropdownDirective implements OnInit, OnDestroy {
this.onHidden = this._dropdown.onHidden;
this.isOpenChange = this._state.isOpenChange;

// set initial dropdown state from config
this._state.autoClose = this._config.autoClose;
}

ngOnInit(): void {
Expand All @@ -163,6 +162,8 @@ export class BsDropdownDirective implements OnInit, OnDestroy {

// attach DOM listeners
this._dropdown.listen({
// because of dropdown inline mode
outsideClick: false,
triggers: this.triggers,
show: () => this.show()
});
Expand Down

0 comments on commit 5cbe131

Please sign in to comment.