Skip to content

Commit f0d9585

Browse files
fix(table): corrige tabela piscando ao realizar scroll
Tabela com muitos itens ao realizar o scroll acontece flickering (piscar) em toda tabela. Extrai o <thead> de dentro do 'cdk-virtual-scroll-viewport' mantendo a visualização da tag ao realizar o scroll. Fix: DTHFUI-13182
1 parent 37e20e3 commit f0d9585

2 files changed

Lines changed: 21 additions & 28 deletions

File tree

projects/ui/src/lib/components/po-table/po-table.component.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,9 @@
621621
@for (column of mainColumns; track trackBy(i); let i = $index) {
622622
<th
623623
class="po-table-header-ellipsis p-element po-frozen-column"
624-
[style.width]="applyFixedColumns() ? column.width : computedColumnWidths[i]"
625-
[style.max-width]="applyFixedColumns() ? column.width : computedColumnWidths[i]"
626-
[style.min-width]="applyFixedColumns() ? column.width : computedColumnWidths[i]"
624+
[style.width]="column.width || computedColumnWidths[i]"
625+
[style.max-width]="column.width || computedColumnWidths[i]"
626+
[style.min-width]="column.width || computedColumnWidths[i]"
627627
[attr.data-po-table-column-name]="column.label || (column.property | titlecase) | lowercase"
628628
[class.po-clickable]="(sort && column.sortable !== false) || hasService"
629629
[ngClass]="{
@@ -658,9 +658,9 @@
658658
@for (column of mainColumns; track trackBy(i); let i = $index) {
659659
<th
660660
class="po-table-header-ellipsis p-element po-frozen-column"
661-
[style.width]="applyFixedColumns() ? column.width : computedColumnWidths[i]"
662-
[style.max-width]="applyFixedColumns() ? column.width : computedColumnWidths[i]"
663-
[style.min-width]="applyFixedColumns() ? column.width : computedColumnWidths[i]"
661+
[style.width]="column.width || computedColumnWidths[i]"
662+
[style.max-width]="column.width || computedColumnWidths[i]"
663+
[style.min-width]="column.width || computedColumnWidths[i]"
664664
[attr.data-po-table-column-name]="column.label || (column.property | titlecase) | lowercase"
665665
[class.po-clickable]="(sort && column.sortable !== false) || hasService"
666666
[ngClass]="{
@@ -774,9 +774,9 @@
774774
}
775775
@for (column of mainColumns; track trackBy(columnIndex); let columnIndex = $index) {
776776
<td
777-
[style.width]="applyFixedColumns() ? column.width : computedColumnWidths[columnIndex]"
778-
[style.max-width]="applyFixedColumns() ? column.width : computedColumnWidths[columnIndex]"
779-
[style.min-width]="applyFixedColumns() ? column.width : computedColumnWidths[columnIndex]"
777+
[style.width]="column.width || computedColumnWidths[columnIndex]"
778+
[style.max-width]="column.width || computedColumnWidths[columnIndex]"
779+
[style.min-width]="column.width || computedColumnWidths[columnIndex]"
780780
[class.po-table-column]="column.type !== 'icon'"
781781
[class.po-table-column-right]="column.type === 'currency' || column.type === 'number'"
782782
[class.po-table-column-center]="column.type === 'subtitle'"

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

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ import {
1111
ContentChildren,
1212
DoCheck,
1313
ElementRef,
14-
Inject,
1514
IterableDiffers,
1615
OnDestroy,
1716
OnInit,
18-
Optional,
1917
QueryList,
2018
Renderer2,
2119
TemplateRef,
@@ -28,12 +26,11 @@ import { Observable, Subscription } from 'rxjs';
2826
import { PoDateService } from '../../services/po-date/po-date.service';
2927
import { PoLanguageService } from '../../services/po-language/po-language.service';
3028
import { PoNotificationService } from '../../services/po-notification/po-notification.service';
31-
import { convertToBoolean, getDefaultSizeFn, PO_TABLE_ROW_HEIGHT_BY_SPACING, uuid } from '../../utils/util';
29+
import { getDefaultSizeFn, PO_TABLE_ROW_HEIGHT_BY_SPACING, PoUtils, uuid } from '../../utils/util';
3230
import { PoModalAction, PoModalComponent } from '../po-modal';
3331
import { PoPopupComponent } from '../po-popup/po-popup.component';
3432
import { PoTableColumnLabel } from './po-table-column-label/po-table-column-label.interface';
3533

36-
import { AnimaliaIconDictionary, ICONS_DICTIONARY } from '../po-icon';
3734
import { PoTableRowTemplateArrowDirection } from './enums/po-table-row-template-arrow-direction.enum';
3835
import { PoTableAction } from './interfaces/po-table-action.interface';
3936
import { PoTableColumn } from './interfaces/po-table-column.interface';
@@ -173,8 +170,7 @@ export class PoTableComponent
173170

174171
private _columnManagerTarget: ElementRef;
175172
private _columnManagerTargetFixed: ElementRef;
176-
private _iconToken: { [key: string]: string };
177-
private differ;
173+
private readonly differ;
178174
private footerHeight;
179175
private timeoutResize;
180176
private visibleElement = false;
@@ -215,21 +211,16 @@ export class PoTableComponent
215211
return this._columnManagerTargetFixed;
216212
}
217213

218-
get iconNameLib() {
219-
return this._iconToken.NAME_LIB;
220-
}
221-
222214
/* eslint-disable max-params */
223215

224216
constructor(
225217
poDate: PoDateService,
226218
differs: IterableDiffers,
227219
private readonly renderer: Renderer2,
228220
poLanguageService: PoLanguageService,
229-
private changeDetector: ChangeDetectorRef,
230-
private decimalPipe: DecimalPipe,
231-
private defaultService: PoTableService,
232-
@Optional() @Inject(ICONS_DICTIONARY) value: { [key: string]: string }
221+
private readonly changeDetector: ChangeDetectorRef,
222+
private readonly decimalPipe: DecimalPipe,
223+
private readonly defaultService: PoTableService
233224
) {
234225
super(poDate, poLanguageService, defaultService);
235226
this.JSON = JSON;
@@ -242,8 +233,6 @@ export class PoTableComponent
242233
this.resizeListener = renderer.listen('window', 'resize', (event: any) => {
243234
this.debounceResize();
244235
});
245-
246-
this._iconToken = value ?? AnimaliaIconDictionary;
247236
}
248237
/* eslint-enable max-params */
249238

@@ -392,8 +381,6 @@ export class PoTableComponent
392381
this.clearColumnWidths();
393382
}
394383

395-
// Permite que os cabeçalhos sejam calculados na primeira vez que o componente torna-se visível,
396-
// evitando com isso, problemas com Tabs ou Divs que iniciem escondidas.
397384
if (this.tableWrapperElement?.nativeElement.offsetWidth && !this.visibleElement && this.initialized) {
398385
this.debounceResize();
399386
this.checkInfiniteScroll();
@@ -597,7 +584,7 @@ export class PoTableComponent
597584

598585
getBooleanLabel(rowValue: any, columnBoolean: PoTableColumn): string {
599586
if (rowValue || rowValue === false || rowValue === 0) {
600-
rowValue = convertToBoolean(rowValue);
587+
rowValue = PoUtils.convertToBoolean(rowValue);
601588

602589
if (columnBoolean.boolean) {
603590
return rowValue ? columnBoolean.boolean.trueLabel || 'Sim' : columnBoolean.boolean.falseLabel || 'Não';
@@ -659,6 +646,12 @@ export class PoTableComponent
659646
this.changeVisibleColumns.emit(columns);
660647
}
661648

649+
onChangeFixedColumns(columns: Array<string>) {
650+
if (!this.hideActionFixedColumns) {
651+
this.changeFixedColumns.emit(columns);
652+
}
653+
}
654+
662655
onColumnRestoreManager(value: Array<string>) {
663656
this.columnRestoreManager.emit(value);
664657
}

0 commit comments

Comments
 (0)