Skip to content

Commit 6d03312

Browse files
authored
Merge branch '15.0.x' into mkirova/feat-12325
2 parents ab094c4 + b992dc1 commit 6d03312

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

projects/igniteui-angular/src/lib/core/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ export class PlatformUtil {
291291
}
292292

293293
range.selectNodeContents(node);
294-
const width = range.getBoundingClientRect().width;
294+
const scale = node.getBoundingClientRect().width / node.offsetWidth;
295+
const width = range.getBoundingClientRect().width / scale;
295296

296297
if (!this.isFirefox) {
297298
// we need that hack - otherwise content won't be measured correctly in IE/Edge

projects/igniteui-angular/src/lib/grids/grid/column-resizing.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,17 @@ describe('IgxGrid - Deferred Column Resizing #grid', () => {
385385
expect(column.width).toEqual('67px');
386386
}));
387387

388+
it('should autosize column correctly if there is scaling via css.', fakeAsync(/** height/width setter rAF */() => {
389+
grid.nativeElement.style.transform = 'scale(0.6)';
390+
const column = grid.getColumnByName('Items');
391+
392+
column.autosize();
393+
fixture.detectChanges();
394+
395+
expect(column.width).toEqual('92px');
396+
grid.nativeElement.style.transform = '';
397+
}));
398+
388399
it('should autosize column programmatically based only on header.', fakeAsync(() => {
389400
const column = fixture.componentInstance.grid.columnList.filter(c => c.field === 'ReleaseDate')[0];
390401
expect(column.width).toEqual('100px');

src/app/grid-column-resizing/grid-column-resizing.sample.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.wrapper {
22
margin: 24px;
3+
transform: scale(0.6);
34
}
45

56
[igxButton]+[igxButton] {

src/app/grid-column-resizing/grid-column-resizing.sample.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</igx-column>
1010
</igx-grid>
1111
<br />
12+
<button igxButton="raised" (click)="autoSizeAll()">AutoSize API</button>
1213
<button igxButton="raised" (click)="toggleColumn('ContactName')">Pin/Unpin 'ContactName'</button>
1314
<button igxButton="raised" (click)="toggleColumn('ContactTitle')">Pin/Unpin 'ContactTitle'</button>
1415
<button igxButton="raised" (click)="toggleColumn('Address')">Pin/Unpin 'Address'</button>

src/app/grid-column-resizing/grid-column-resizing.sample.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class GridColumnResizingSampleComponent implements OnInit {
2323
// % width, no min/max width.
2424
{ field: 'ContactName', width: '20%', resizable: true },
2525
// % width, % min/max width.
26-
{ field: 'ContactTitle', width: '30%', resizable: true, maxWidth: '5%'},
26+
{ field: 'ContactTitle', width: '30%', resizable: true, maxWidth: '30%'},
2727
// px width, % min/max width.
2828
{ field: 'Address', width: 300, resizable: true, maxWidth: '20%', minWidth: '15%' },
2929
{ field: 'City', width: 100, resizable: true },
@@ -73,4 +73,8 @@ export class GridColumnResizingSampleComponent implements OnInit {
7373
public scrScrollTo(index) {
7474
this.grid1.verticalScrollContainer.scrollTo(parseInt(index, 10));
7575
}
76+
77+
public autoSizeAll() {
78+
this.grid1.columns.forEach(x => x.autosize());
79+
}
7680
}

0 commit comments

Comments
 (0)