Skip to content

Commit

Permalink
feat(dropdown): add option to let event propagate on toggle
Browse files Browse the repository at this point in the history
Issue #1217 was fixed but re-introduce
recently in development branch (commit 04cab1e).

Let's add an option to authorize propagation of click event on toggle
for users that need it.
  • Loading branch information
H--o-l committed Nov 2, 2017
1 parent 69bd6fa commit 82e7832
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/dropdown/bs-dropdown-toggle.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ElementRef,
HostBinding,
HostListener,
Input,
OnDestroy
} from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
Expand All @@ -17,6 +18,11 @@ 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 @@ -41,7 +47,10 @@ export class BsDropdownToggleDirective implements OnDestroy {

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

if (this.isDisabled) {
return;
}
Expand Down

0 comments on commit 82e7832

Please sign in to comment.