Skip to content

Commit

Permalink
fix: improve resizing column min width logic (#3589)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Mar 23, 2022
1 parent 8f397a2 commit afe1316
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/grid/src/vaadin-grid-column-resizing-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const ColumnResizingMixin = (superClass) =>
const targetCell = columnRowCells.filter((cell) => cell._column === column)[0];
// Resize the target column
if (targetCell.offsetWidth) {
const style = window.getComputedStyle(targetCell);
const style = getComputedStyle(targetCell._content);
const minWidth =
10 +
parseInt(style.paddingLeft) +
Expand Down
13 changes: 13 additions & 0 deletions packages/grid/test/column-resizing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ describe('column resizing', () => {
});
});

it('should set min width based on cell content padding', () => {
const options = { node: handle };
const rect = headerCells[0].getBoundingClientRect();

const contentStyle = getComputedStyle(headerCells[0]._content);
const padding = parseInt(contentStyle.paddingLeft) + parseInt(contentStyle.paddingRight);

fire('track', { state: 'start' }, options);
fire('track', { state: 'track', x: rect.left - 100, y: 0 }, options);

expect(headerCells[0].clientWidth).to.be.greaterThan(padding);
});

it('should not listen to track event on scroller', () => {
const scroller = grid.$.scroller;
fire('track', { state: 'start' }, { node: scroller });
Expand Down

0 comments on commit afe1316

Please sign in to comment.