Skip to content

Commit 0a863c1

Browse files
committed
fix(popover): use afterRenderEffect() instead of effect() to avoid NG0500: During hydration expected...
1 parent 8f77e2d commit 0a863c1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

projects/coreui-angular/src/lib/popover/popover.directive.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
afterRenderEffect,
23
AfterViewInit,
34
ChangeDetectorRef,
45
ComponentRef,
@@ -100,8 +101,12 @@ export class PopoverDirective implements OnDestroy, OnInit, AfterViewInit {
100101
*/
101102
readonly visible = model(false, { alias: 'cPopoverVisible' });
102103

103-
readonly #visibleEffect = effect(() => {
104-
this.visible() ? this.addTooltipElement() : this.removeTooltipElement();
104+
readonly #visibleEffect = afterRenderEffect({
105+
// this fixes RuntimeError: NG0500: During hydration Angular expected <abc> but found <xyz>.
106+
// Find more at https://angular.dev/errors/NG0500
107+
write: () => {
108+
this.visible() ? this.addTooltipElement() : this.removeTooltipElement();
109+
}
105110
});
106111

107112
get ariaDescribedBy(): string | null {

0 commit comments

Comments
 (0)