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
2 changes: 1 addition & 1 deletion docs
Submodule docs updated 275 files
65 changes: 65 additions & 0 deletions e2e/virtualization.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,71 @@ test.describe('virtualization', () => {
expect(visibleNames.includes('Name 151')).toBe(true);
});

test('keeps the last row visible with horizontal overflow after resize', async ({ page }) => {
const rowSize = 46;
const rowCount = 100;
const lastRow = rowCount - 1;
const columnProps = Array.from({ length: 12 }, (_, index) => `c${index}`);
const source = Array.from({ length: rowCount }, (_, rowIndex) =>
Object.fromEntries(
columnProps.map((prop, columnIndex) => [
prop,
`${rowIndex}:${columnIndex}`,
]),
),
);

await mountGrid(page, {
width: 760,
height: 360,
rowHeaders: true,
rowSize,
columns: columnProps.map((prop, index) => ({
prop,
name: String.fromCharCode(65 + index),
size: 170,
})),
source,
});

const assertLastRowInsideViewport = async () => {
await expect(dataCell(page, lastRow, 0)).toHaveText(`${lastRow}:0`);
const boxes = await page.evaluate(({ viewportSelector, cellSelector }) => {
const viewport = document.querySelector<HTMLElement>(viewportSelector);
const cell = document.querySelector<HTMLElement>(cellSelector);
if (!viewport || !cell) {
throw new Error('Expected viewport and last-row cell to be rendered');
}
const viewportBox = viewport.getBoundingClientRect();
const cellBox = cell.getBoundingClientRect();
return {
viewportBottom: viewportBox.bottom,
cellBottom: cellBox.bottom,
};
}, {
viewportSelector: `${SELECTORS.mainViewport} .vertical-inner`,
cellSelector: `${SELECTORS.mainViewport} revogr-data[type="rgRow"] [data-rgrow="${lastRow}"] [data-rgcol="0"]`,
});
expect(boxes.cellBottom).toBeLessThanOrEqual(boxes.viewportBottom + 1);
};

await scrollToCell(page, 0, lastRow * rowSize);
await assertLastRowInsideViewport();

await page.evaluate(() => {
const holder = document.querySelector<HTMLElement>('revo-grid')?.parentElement;
if (!holder) {
throw new Error('Grid holder was not found');
}
holder.style.width = '980px';
holder.style.height = '620px';
});
await page.waitForChanges();

await scrollToCell(page, 0, lastRow * rowSize);
await assertLastRowInsideViewport();
});

test('scrolls to rows beyond browser-native scroll height limits', async ({ page }) => {
const rowSize = 30;
const rowCount = 1_200_000;
Expand Down
2 changes: 1 addition & 1 deletion formats/date
2 changes: 1 addition & 1 deletion formats/number
2 changes: 1 addition & 1 deletion packages/react
2 changes: 1 addition & 1 deletion packages/vue2
2 changes: 1 addition & 1 deletion packages/vue3
1 change: 1 addition & 0 deletions src/components/revoGrid/viewport.resize.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default class GridResizeService {
}

destroy() {
this.apply.cancel();
this.resizeObserver?.disconnect();
this.resizeObserver = null;
}
Expand Down
35 changes: 23 additions & 12 deletions src/components/scroll/revogr-viewport-scroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ export class RevogrViewportScroll implements ElementScroll {
scroll: this.horizontalScroll.scrollLeft,
noScroll: this.colType !== 'rgCol',
};
this.setScrollParams({
rgRow: calculatedHeight,
rgCol: calculatedWidth,
});
// Process changes in order: width first, then height
const dimensions: DimensionType[] = ['rgCol', 'rgRow'];
for (const dimension of dimensions) {
Expand Down Expand Up @@ -311,10 +315,27 @@ export class RevogrViewportScroll implements ElementScroll {
}

async componentDidRender() {
this.setScrollParams({
rgRow: this.verticalScroll?.clientHeight ?? 0,
rgCol: this.horizontalScroll.clientWidth,
});
this.setScrollVisibility(
'rgRow',
this.verticalScroll?.clientHeight ?? 0,
this.contentHeight,
);
this.setScrollVisibility(
'rgCol',
this.horizontalScroll.clientWidth,
this.contentWidth,
);
}

private setScrollParams(clientSize: Record<DimensionType, number>) {
this.localScrollService.setParams(
{
contentSize: this.contentHeight,
clientSize: this.verticalScroll?.clientHeight ?? 0,
clientSize: clientSize.rgRow,
virtualSize: 0,
},
'rgRow',
Expand All @@ -323,21 +344,11 @@ export class RevogrViewportScroll implements ElementScroll {
this.localScrollService.setParams(
{
contentSize: this.contentWidth,
clientSize: this.horizontalScroll.clientWidth,
clientSize: clientSize.rgCol,
virtualSize: 0,
},
'rgCol',
);
this.setScrollVisibility(
'rgRow',
this.verticalScroll?.clientHeight ?? 0,
this.contentHeight,
);
this.setScrollVisibility(
'rgCol',
this.horizontalScroll.clientWidth,
this.contentWidth,
);
}

render() {
Expand Down
Loading