Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Popover: Does not update parent view on shown event #3896

Closed
Nosfistis opened this issue Nov 11, 2020 · 0 comments · Fixed by #3909
Closed

Popover: Does not update parent view on shown event #3896

Nosfistis opened this issue Nov 11, 2020 · 0 comments · Fixed by #3909

Comments

@Nosfistis
Copy link

Bug description:

This is a regression bug of 8.0.0 release.

I have a subject that fires on each shown/hidden event, and is merged to an observable to update a count:

  count$: Observable<number> = merge(
    interval(3000),
    this.isShownSubject.pipe(mapTo(0))
  );

However, the view does not update on shown. Even though the event is fired, and the observable emits, the entire containing view does not update at all. The hidden event works as intended.

I have checked the current code and realized that the NgbPopover.close() marks for change detection after the hidden event is fired, but the NgbPopover.open() does not. Code:

transition$.subscribe(() => this.shown.emit());

close() {
if (this._windowRef) {
this._renderer.removeAttribute(this._elementRef.nativeElement, 'aria-describedby');
this._popupService.close(this.animation).subscribe(() => {
this._windowRef = null;
this.hidden.emit();
this._changeDetector.markForCheck();
});
}
}

I have manually tried adding the this._changeDetector.markForCheck(), but the view still does not update. Only explicitly adding this._changeDetector.detectChanges() fixes the issue.

It is even stranger that not only the directive content, but also the entire parent component view does not update (in the StackBlitz, the description bottom text does not change either). This occurs in OnPush and Default change detection strategies, even with animations disabled.

Link to minimally-working StackBlitz that reproduces the issue:

https://stackblitz.com/edit/angular-vsfpjy

Versions of Angular, ng-bootstrap and Bootstrap:

Angular: 10.2.3

ng-bootstrap: 8.0.0

Bootstrap: 4.5.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants