Skip to content

Commit 2c7b820

Browse files
committed
fix(for-of): address bordered sizing review feedback
1 parent 6677e3c commit 2c7b820

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,19 @@ describe('IgxForOf directive -', () => {
375375
virtualContainer.igxForSizePropName = 'width';
376376
const horizontalSize = node.getBoundingClientRect().width + 5 + 11;
377377
expect(virtualContainer.testGetNodeSize(node)).toBe(horizontalSize);
378+
379+
node.remove();
380+
});
381+
382+
it('should preserve valid border sizes when another side cannot be parsed', () => {
383+
const virtualContainer = fix.componentInstance.parentVirtDir;
384+
const node = document.createElement('div');
385+
spyOn(window, 'getComputedStyle').and.returnValue({
386+
borderTopWidth: '',
387+
borderBottomWidth: '2px'
388+
} as CSSStyleDeclaration);
389+
390+
expect(virtualContainer.testGetBorder(node, 'height')).toBe(2);
378391
});
379392

380393
it('should render no more that initial chunk size elements when set if no containerSize', () => {
@@ -1409,6 +1422,10 @@ export class TestIgxForOfDirective<T> extends IgxForOfDirective<T> {
14091422
public testGetNodeSize(node: Element): number {
14101423
return super.getNodeSize(node, 0);
14111424
}
1425+
1426+
public testGetBorder(node: Element, dimension: string): number {
1427+
return super.getBorder(node, dimension);
1428+
}
14121429
}
14131430

14141431
/** Empty virtualized component */

projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,11 +1570,11 @@ export class IgxForOfDirective<T, U extends T[] = T[]> extends IgxForOfToken<T,U
15701570
protected getBorder(node, dimension: string): number {
15711571
const styles = window.getComputedStyle(node);
15721572
if (dimension === 'height') {
1573-
return parseFloat(styles['borderTopWidth']) +
1574-
parseFloat(styles['borderBottomWidth']) || 0;
1573+
return (parseFloat(styles['borderTopWidth']) || 0) +
1574+
(parseFloat(styles['borderBottomWidth']) || 0);
15751575
}
1576-
return parseFloat(styles['borderLeftWidth']) +
1577-
parseFloat(styles['borderRightWidth']) || 0;
1576+
return (parseFloat(styles['borderLeftWidth']) || 0) +
1577+
(parseFloat(styles['borderRightWidth']) || 0);
15781578
}
15791579
}
15801580

projects/igniteui-angular/grids/grid/src/grid-filtering-ui.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4093,6 +4093,7 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
40934093

40944094
const searchComponent = fix.debugElement.query(By.css('igx-excel-style-search')).componentInstance;
40954095
const listElement = searchComponent.list.element.nativeElement as HTMLElement;
4096+
listElement.style.border = '1px solid transparent';
40964097

40974098
expect(listElement.offsetHeight).toBeGreaterThan(listElement.clientHeight);
40984099
expect(searchComponent.containerSize).toBe(listElement.clientHeight);

0 commit comments

Comments
 (0)