Skip to content

Commit

Permalink
fix: use offsetWidth for column auto width calculation (#1745)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki authored and web-padawan committed Jun 4, 2020
1 parent e3bd716 commit d64b99b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/vaadin-grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,7 @@
col._currentWidth = 0;
// Note: _allCells only contains cells which are currently rendered in DOM
col._allCells.forEach(c => {
const cellWidth = Math.ceil(c.getBoundingClientRect().width);
col._currentWidth = Math.max(col._currentWidth, cellWidth);
col._currentWidth = Math.max(col._currentWidth, c.offsetWidth);
});
});
// [write] Set column widths to fit widest measured content
Expand Down
10 changes: 10 additions & 0 deletions test/column-auto-width.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@
});
});

it('should have correct column widths when the grid is visually scaled', done => {
grid.style.transform = 'scale(0.5)';
grid.items = testItems;

whenColumnWidthsCalculated(() => {
expectColumnWidthsToBeOk(columns);
done();
});
});

it('should have correct column widths when using lazy dataProvider', done => {
grid.dataProvider = (params, callback) => {
requestAnimationFrame(() => {
Expand Down

0 comments on commit d64b99b

Please sign in to comment.