Skip to content

Commit 368f92d

Browse files
vaadin-botvursen
andauthored
fix: render all rows on deep expand with all-rows-visible (#12146) (#12150)
Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
1 parent 54a6857 commit 368f92d

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

packages/component-base/src/virtualizer-iron-list-adapter.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class IronListAdapter {
2222
reorderElements,
2323
elementsContainer,
2424
__disableHeightPlaceholder,
25+
__alwaysUpdateScrollerSize,
2526
}) {
2627
this.isAttached = true;
2728
this._vidxOffset = 0;
@@ -37,6 +38,12 @@ export class IronListAdapter {
3738
// elements with a non-zero height. Not for public use.
3839
this.__disableHeightPlaceholder = __disableHeightPlaceholder ?? false;
3940

41+
// Internal option: a predicate that, when it returns true, makes the scroller
42+
// height always be applied instead of amortized (see `_updateScrollerSize`).
43+
// Used by components whose height tracks the content exactly (e.g. the grid's
44+
// `allRowsVisible` mode). Not for public use.
45+
this.__alwaysUpdateScrollerSize = __alwaysUpdateScrollerSize;
46+
4047
// Iron-list uses this value to determine how many pages of elements to render
4148
this._maxPages = 1.3;
4249

@@ -216,6 +223,11 @@ export class IronListAdapter {
216223
this.__afterElementsUpdated(updatedElements);
217224
}
218225

226+
/** @override */
227+
_updateScrollerSize(forceUpdate) {
228+
super._updateScrollerSize(forceUpdate || !!this.__alwaysUpdateScrollerSize?.());
229+
}
230+
219231
/**
220232
* Updates the height for a given set of items.
221233
*

packages/grid/src/vaadin-grid-mixin.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@ export const GridMixin = (superClass) =>
247247
// otherwise be triggered by this logic because it reads the row height
248248
// right after updating the rows' content.
249249
__disableHeightPlaceholder: true,
250+
// The virtualizer amortizes scroller height updates to avoid reflows while
251+
// scrolling. In `allRowsVisible` mode the grid has no scrolling and its
252+
// height must track the content exactly, so tell the virtualizer to always
253+
// apply the scroller height. Otherwise the items container can be left at a
254+
// stale, too-small height and clip rows when the grid grows (e.g. when
255+
// expanding a tree grid from a small size).
256+
__alwaysUpdateScrollerSize: () => this.allRowsVisible,
250257
});
251258

252259
this._tooltipController = new TooltipController(this);

packages/grid/test/resizing.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ describe('all rows visible', () => {
339339
};
340340
cb([item], 1);
341341
};
342+
flushGrid(grid);
342343
});
343344

344345
it('should have all rows visible on deep expand', () => {
@@ -359,6 +360,9 @@ describe('all rows visible', () => {
359360
});
360361

361362
it('should have all rows visible on deep expand with no header', () => {
363+
const column = grid.querySelector('vaadin-grid-tree-column');
364+
column.header = null;
365+
362366
grid.expandedItems = [
363367
{ value: '0' },
364368
{ value: '0-0' },
@@ -370,9 +374,6 @@ describe('all rows visible', () => {
370374
{ value: '0-0-0-0-0-0-0-0' },
371375
];
372376

373-
const column = grid.querySelector('vaadin-grid-tree-column');
374-
column.header = null;
375-
376377
flushGrid(grid);
377378
expect(grid._firstVisibleIndex).to.equal(0);
378379
expect(grid._lastVisibleIndex).to.equal(8);

0 commit comments

Comments
 (0)