Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/grid/src/vaadin-grid-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,14 @@ export const GridMixin = (superClass) =>
__disableHeightPlaceholder: true,
});

new ResizeObserver(() =>
new ResizeObserver(() => {
setTimeout(() => {
this.__updateColumnsBodyContentHidden();
}),
).observe(this.$.table);
});
// Updating data can change the visibility of the scroll bar. Therefore,
// the scroll position has to be recalculated.
this.__updateHorizontalScrollPosition();
}).observe(this.$.table);

const minHeightObserver = new ResizeObserver(() =>
setTimeout(() => {
Expand Down
25 changes: 25 additions & 0 deletions packages/grid/test/frozen-columns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,31 @@ const frozenGridFixture = (frozen, frozenToEnd) => {
expect(getComputedStyle(sizerCell).transform).to.equal('none');
});

it('should update frozen-to-end positioning when scrollbar affects layout during data changes', async () => {
grid.style.width = '200px';
// Simulate a wide scrollbar like with Windows
const scrollbarWidth = 17;
const originalClientWidth = grid.$.table.clientWidth;
grid.$.table.style.width = `${originalClientWidth - scrollbarWidth}px`;
flushGrid(grid);
await nextRender();

const getFrozenToEndHeaderCell = () => getRowCells(getRows(grid.$.header)[0])[2];
const positionWithScrollbar = getFrozenToEndHeaderCell().getBoundingClientRect().x;

grid.items = Array.from({ length: 2 }, (_, i) => ({
foo: `foo${i}`,
bar: `bar${i}`,
baz: `baz${i}`,
}));
grid.$.table.style.width = `${originalClientWidth}px`;
flushGrid(grid);
await nextRender();

const positionAfterDataChange = getFrozenToEndHeaderCell().getBoundingClientRect().x;
expect(positionWithScrollbar).to.not.equal(positionAfterDataChange);
});

['header', 'body'].forEach((container) => {
describe(container, () => {
const defaultCellWidth = 100;
Expand Down