Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check if sizer cells are assigned for lazy column rendering (#7292) (CP: 24.3) #7309

Merged
merged 1 commit into from
Apr 9, 2024
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
15 changes: 7 additions & 8 deletions packages/grid/src/vaadin-grid-scroll-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,11 @@ export const ScrollMixin = (superClass) =>

/** @private */
__updateColumnsBodyContentHidden() {
if (!this._columnTree) {
if (!this._columnTree || !this._areSizerCellsAssigned()) {
return;
}

const columnsInOrder = this._getColumnsInOrder();

// Return if sizer cells are not yet assigned to columns
if (!columnsInOrder[0] || !columnsInOrder[0]._sizerCell) {
return;
}

let bodyContentHiddenChanged = false;

// Remove the column cells from the DOM if the column is outside the viewport.
Expand Down Expand Up @@ -485,7 +479,7 @@ export const ScrollMixin = (superClass) =>

let transformFrozenToEndBody = transformFrozenToEnd;

if (this._lazyColumns) {
if (this._lazyColumns && this._areSizerCellsAssigned()) {
// Lazy column rendering is used, calculate the offset to apply to the frozen to end cells
const columnsInOrder = this._getColumnsInOrder();

Expand Down Expand Up @@ -515,4 +509,9 @@ export const ScrollMixin = (superClass) =>
this.$.table.style.setProperty('--_grid-horizontal-scroll-position', `${-x}px`);
}
}

/** @private */
_areSizerCellsAssigned() {
return this._getColumnsInOrder().every((column) => column._sizerCell);
}
};
17 changes: 17 additions & 0 deletions packages/grid/test/column-rendering.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,23 @@ import { flushGrid, getCellContent, getHeaderCellContent, onceResized } from './
expect(secondRect.top).to.equal(firstRect.bottom + detailsHeight);
});

it('should render new appended column', async () => {
grid = fixtureSync(`
<vaadin-grid item-id-path="name" column-rendering="lazy">
<vaadin-grid-column path="name"></vaadin-grid-column>
</vaadin-grid>
`);
grid.items = [{ name: `Item 1` }];
await onceResized(grid);
flushGrid(grid);

const newColumn = document.createElement('vaadin-grid-column');
grid.appendChild(newColumn);
await nextFrame();

expect(isColumnInViewport(newColumn)).to.be.true;
});

describe(`scroll horizontally - ${dir}`, () => {
/**
* Expect the cells DOM order to match the column order
Expand Down
Loading