Skip to content

Commit 7ded538

Browse files
committed
fix(dropdown): prevent ng router active link double ngOnInit issue
read more: #1885 refs #1885
1 parent dfe508f commit 7ded538

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/dropdown/bs-dropdown.directive.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export class BsDropdownDirective implements OnInit, OnDestroy {
109109
private _isDisabled: boolean;
110110
private _dropdown: ComponentLoader<BsDropdownContainerComponent>;
111111
private _subscriptions: Subscription[] = [];
112+
private _isInited = false;
112113

113114
constructor(private _elementRef: ElementRef,
114115
private _renderer: Renderer,
@@ -129,6 +130,12 @@ export class BsDropdownDirective implements OnInit, OnDestroy {
129130
}
130131

131132
ngOnInit(): void {
133+
// fix: seems there are an issue with `routerLinkActive`
134+
// which result in duplicated call ngOnInit without call to ngOnDestroy
135+
// read more: https://github.com/valor-software/ngx-bootstrap/issues/1885
136+
if (this._isInited) {return;}
137+
this._isInited = true;
138+
132139
this._showInline = !this.container;
133140

134141
// attach DOM listeners

0 commit comments

Comments
 (0)