@@ -40,10 +40,11 @@ export class PopoverDirective implements OnChanges, OnDestroy, OnInit {
4040 */
4141 @Input ( 'cPopoverOptions' )
4242 set popperOptions ( value : Partial < Options > ) {
43- this . _popperOptions = { ...this . _popperOptions , placement : this . placement , ...value } ;
43+ this . _popperOptions = { ...this . _popperOptions , placement : this . placement , ...value } ;
4444 } ;
45+
4546 get popperOptions ( ) : Partial < Options > {
46- return { placement : this . placement , ...this . _popperOptions } ;
47+ return { placement : this . placement , ...this . _popperOptions } ;
4748 }
4849
4950 /**
@@ -63,11 +64,17 @@ export class PopoverDirective implements OnChanges, OnDestroy, OnInit {
6364 set visible ( value : boolean ) {
6465 this . _visible = value ;
6566 }
67+
6668 get visible ( ) {
6769 return this . _visible ;
6870 }
71+
6972 private _visible = false ;
7073
74+ @HostBinding ( 'attr.aria-describedby' ) get ariaDescribedBy ( ) : string | null {
75+ return this . popoverId ? this . popoverId : null ;
76+ }
77+
7178 private popover ! : HTMLDivElement ;
7279 private popoverId ! : string ;
7380 private popoverRef ! : ComponentRef < PopoverComponent > ;
@@ -78,10 +85,10 @@ export class PopoverDirective implements OnChanges, OnDestroy, OnInit {
7885 {
7986 name : 'offset' ,
8087 options : {
81- offset : [ 0 , 8 ] ,
82- } ,
83- } ,
84- ] ,
88+ offset : [ 0 , 8 ]
89+ }
90+ }
91+ ]
8592 } ;
8693
8794 constructor (
@@ -99,17 +106,12 @@ export class PopoverDirective implements OnChanges, OnDestroy, OnInit {
99106 }
100107 }
101108
102- @HostBinding ( 'attr.aria-describedby' ) get ariaDescribedBy ( ) : string | null {
103- return this . popoverId ? this . popoverId : null ;
104- }
105-
106109 ngOnDestroy ( ) : void {
107110 this . clearListeners ( ) ;
108111 this . destroyPopoverElement ( ) ;
109112 }
110113
111114 ngOnInit ( ) : void {
112- // this.createPopoverElement();
113115 this . setListeners ( ) ;
114116 }
115117
@@ -129,8 +131,8 @@ export class PopoverDirective implements OnChanges, OnDestroy, OnInit {
129131 this . visible = true ;
130132 this . addPopoverElement ( ) ;
131133 }
132- }
133- this . listenersService . setListeners ( config )
134+ } ;
135+ this . listenersService . setListeners ( config ) ;
134136 }
135137
136138 private clearListeners ( ) : void {
@@ -171,38 +173,33 @@ export class PopoverDirective implements OnChanges, OnDestroy, OnInit {
171173 this . popoverRef . instance . content = this . content ;
172174 this . popover = this . popoverRef . location . nativeElement ;
173175 this . renderer . addClass ( this . popover , 'fade' ) ;
174- // this.renderer.setStyle(this.popover, 'visibility', 'hidden')
175176
176177 setTimeout ( ( ) => {
177178 this . popperInstance = createPopper (
178179 this . hostElement . nativeElement ,
179180 this . popover ,
180- { ...this . popperOptions }
181+ { ...this . popperOptions }
181182 ) ;
182183 this . viewContainerRef . insert ( this . popoverRef . hostView ) ;
183184 setTimeout ( ( ) => {
184185 this . popoverId = this . getUID ( 'popover' ) ;
185186 this . popoverRef . instance . id = this . popoverId ;
186187 this . popoverRef . instance . visible = this . visible ;
187- // this.renderer.removeStyle(this.popover, 'visibility');
188188 this . renderer . appendChild ( this . document . body , this . popover ) ;
189189 this . popperInstance . forceUpdate ( ) ;
190- // this.popoverRef.changeDetectorRef.detectChanges ();
190+ // this.popoverRef.changeDetectorRef.markForCheck ();
191191 } , 100 ) ;
192- } )
192+ } ) ;
193193 }
194194
195195 private removePopoverElement ( ) : void {
196196 if ( ! this . popoverRef ) {
197197 return ;
198198 }
199199 this . popoverRef . instance . visible = this . visible ;
200- // this.popoverRef.changeDetectorRef?.detectChanges();
201200 this . popoverRef . instance . id = undefined ;
202201 setTimeout ( ( ) => {
203202 this . viewContainerRef . detach ( ) ;
204- // this.viewContainerRef.remove();
205- // this.renderer.removeChild(this.document.body, this.popover);
206203 this . popperInstance ?. destroy ( ) ;
207204 this . popoverId = '' ;
208205 } , 300 ) ;
0 commit comments