Skip to content

Commit 1a93f13

Browse files
committed
chore(*): Fix for autize headers when sizes are not round number. Fix column pinning integration.
1 parent 9cf467d commit 1a93f13

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

projects/igniteui-angular/src/lib/grids/columns/column.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,8 @@ export class IgxColumnComponent implements AfterContentInit {
17541754
*/
17551755
public autosize(byHeader = false) {
17561756
if (!this.columnGroup) {
1757-
this.width = !byHeader ? this.getLargestCellWidth() : Object.values(this.getHeaderCellWidths()).reduce((a, b) => a + b);
1757+
this.width = !byHeader ? this.getLargestCellWidth() :
1758+
(Object.values(this.getHeaderCellWidths()).reduce((a, b) => a + b) + 'px');
17581759
this.grid.reflow();
17591760
}
17601761
}
@@ -1792,7 +1793,12 @@ export class IgxColumnComponent implements AfterContentInit {
17921793
const headerStyle = this.grid.document.defaultView.getComputedStyle(this.headerCell.elementRef.nativeElement);
17931794
const headerPadding = parseFloat(headerStyle.paddingLeft) + parseFloat(headerStyle.paddingRight) +
17941795
parseFloat(headerStyle.borderRightWidth);
1795-
return { width: headerWidth, padding: headerPadding};
1796+
1797+
// Take into consideration the header group element, since column pinning applies borders to it if its not a columnGroup.
1798+
const headerGroupStyle = this.grid.document.defaultView.getComputedStyle(this.headerGroup.element.nativeElement);
1799+
const borderSize = !this.parent ? parseFloat(headerGroupStyle.borderRightWidth) + parseFloat(headerGroupStyle.borderLeftWidth) : 0;
1800+
1801+
return { width: Math.ceil(headerWidth), padding: Math.ceil(headerPadding + borderSize)};
17961802
}
17971803

17981804
/**
@@ -1821,7 +1827,7 @@ export class IgxColumnComponent implements AfterContentInit {
18211827
const index = cellsContentWidths.indexOf(Math.max(...cellsContentWidths));
18221828
const cellStyle = this.grid.document.defaultView.getComputedStyle(this.cells[index].nativeElement);
18231829
const cellPadding = parseFloat(cellStyle.paddingLeft) + parseFloat(cellStyle.paddingRight) +
1824-
parseFloat(cellStyle.borderRightWidth);
1830+
parseFloat(cellStyle.borderLeftWidth) + parseFloat(cellStyle.borderRightWidth);
18251831

18261832
largest.set(Math.max(...cellsContentWidths), cellPadding);
18271833
}

0 commit comments

Comments
 (0)