Skip to content

Commit ac2ef6a

Browse files
committed
fix(popover): corrige posicionamento no po-table com virtual scroll
Adiciona `p-append-in-body` para corrigir o posicionamento do `po-popover` quando usado dentro de um `po-table` com altura definida e virtual scroll habilitado. fixes DTHFUI-7133
1 parent 720242c commit ac2ef6a

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

projects/ui/src/lib/components/po-popover/po-popover-base.component.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ const PO_POPOVER_TRIGGERS = ['click', 'hover'];
2828
*/
2929
@Directive()
3030
export class PoPopoverBaseComponent {
31+
/**
32+
* @optional
33+
*
34+
* @description
35+
*
36+
* Define que o popover será inserido no body da página em vez do elemento definido em `p-target`. Essa opção pode
37+
* ser necessária em cenários com containers que possuem scroll ou overflow escondido, garantindo o posicionamento
38+
* correto do conteúdo próximo ao elemento.
39+
*
40+
* @default `false`
41+
*/
42+
43+
@Input({ alias: 'p-append-in-body', transform: convertToBoolean }) appendBox: boolean = false;
3144
/**
3245
* @description
3346
*
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1-
<div [hidden]="isHidden" class="po-popover" #popoverElement>
2-
<div *ngIf="!hideArrow" class="po-popover-arrow po-arrow-{{ arrowDirection }}"></div>
1+
<ng-container *ngIf="appendBox; then popoverCDK; else popoverDefault"> </ng-container>
32

4-
<div class="po-popover-content">
5-
<span *ngIf="title" class="po-popover-title">{{ title }}</span>
6-
<ng-content></ng-content>
3+
<ng-template #sharedPopoverContent>
4+
<div [hidden]="isHidden" class="po-popover" #popoverElement>
5+
<div *ngIf="!hideArrow" class="po-popover-arrow po-arrow-{{ arrowDirection }}"></div>
6+
7+
<div class="po-popover-content">
8+
<span *ngIf="title" class="po-popover-title">{{ title }}</span>
9+
<ng-content></ng-content>
10+
</div>
711
</div>
8-
</div>
12+
</ng-template>
13+
14+
<ng-template #popoverDefault>
15+
<ng-container *ngTemplateOutlet="sharedPopoverContent"></ng-container>
16+
</ng-template>
17+
18+
<ng-template #popoverCDK>
19+
<ng-template cdkConnectedOverlay [cdkConnectedOverlayOrigin]="target" [cdkConnectedOverlayOpen]="true">
20+
<ng-container *ngTemplateOutlet="sharedPopoverContent"></ng-container>
21+
</ng-template>
22+
</ng-template>

projects/ui/src/lib/components/po-popover/po-popover.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { PoPopoverBaseComponent } from './po-popover-base.component';
4040
standalone: false
4141
})
4242
export class PoPopoverComponent extends PoPopoverBaseComponent implements AfterViewInit, OnDestroy {
43-
@ViewChild('popoverElement', { read: ElementRef, static: true }) popoverElement: ElementRef;
43+
@ViewChild('popoverElement', { read: ElementRef, static: false }) popoverElement: ElementRef;
4444

4545
arrowDirection = 'left';
4646
timeoutResize;

projects/ui/src/lib/components/po-popover/po-popover.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CommonModule } from '@angular/common';
22
import { NgModule } from '@angular/core';
3+
import { OverlayModule } from '@angular/cdk/overlay';
34

45
import { PoPopoverComponent } from './po-popover.component';
56

@@ -8,7 +9,7 @@ import { PoPopoverComponent } from './po-popover.component';
89
* Módulo do componente po-popover.
910
*/
1011
@NgModule({
11-
imports: [CommonModule],
12+
imports: [CommonModule, OverlayModule],
1213
declarations: [PoPopoverComponent],
1314
exports: [PoPopoverComponent]
1415
})

0 commit comments

Comments
 (0)