Skip to content

Commit 4fb94de

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Refactor tbody width calculations.
1 parent bf5c1d7 commit 4fb94de

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6498,16 +6498,12 @@ export abstract class IgxGridBaseDirective implements GridType,
64986498

64996499
if (this.isPercentWidth) {
65006500
/* width in %*/
6501-
const computed = this.document.defaultView.getComputedStyle(this.nativeElement).getPropertyValue('width');
6502-
width = computed.indexOf('%') === -1 ? parseFloat(computed) : null;
6501+
const computed = this.document.defaultView.getComputedStyle(this.tbody.nativeElement).getPropertyValue('width');
6502+
width = parseFloat(computed);
65036503
} else {
65046504
width = parseInt(this.width, 10);
65056505
}
65066506

6507-
if (!width && this.nativeElement) {
6508-
width = this.nativeElement.offsetWidth;
6509-
}
6510-
65116507

65126508
if (this.width === null || !width) {
65136509
this.isColumnWidthSum = true;
@@ -6516,9 +6512,6 @@ export abstract class IgxGridBaseDirective implements GridType,
65166512
this.isColumnWidthSum = false;
65176513
}
65186514

6519-
if (this.hasVerticalScroll() && this.width !== null) {
6520-
width -= this.scrollSize;
6521-
}
65226515
if ((Number.isFinite(width) || width === null) && width !== this.calcWidth) {
65236516
this.calcWidth = width;
65246517
}

projects/igniteui-angular/src/lib/grids/grid/grid.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<div class="igx-grid__tbody-content" tabindex="0" [attr.role]="dataView.length ? null : 'row'" (keydown)="navigation.handleNavigation($event)" (focus)="navigation.focusTbody($event)"
3535
(dragStop)="selectionService.dragMode = $event" (scroll)="preventContainerScroll($event)"
3636
(dragScroll)="dragScroll($event)" [igxGridDragSelect]="selectionService.dragMode"
37-
[style.height.px]="totalHeight" [style.width.px]="calcWidth || null" #tbody [attr.aria-activedescendant]="activeDescendant">
37+
[style.height.px]="totalHeight" #tbody [attr.aria-activedescendant]="activeDescendant">
3838
@if (moving && columnInDrag && pinnedColumns.length <= 0) {
3939
<span
4040
[igxColumnMovingDrop]="headerContainer" [attr.droppable]="true" id="left"

0 commit comments

Comments
 (0)