Skip to content

Commit

Permalink
Fixes virtualized Table empty content (#2161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Pusey-Bentley authored Jul 23, 2024
1 parent 88e2826 commit 35dcd4f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-kangaroos-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-react': patch
---

Fixed issue where `emptyTableContent` would not appear on virutalized `Table` components.
2 changes: 1 addition & 1 deletion packages/itwinui-react/src/core/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ export const Table = <
}
>
<ShadowRoot>
{enableVirtualization ? (
{enableVirtualization && data.length !== 0 ? (
<div
style={{
minBlockSize: virtualizer.getTotalSize(),
Expand Down
19 changes: 10 additions & 9 deletions testing/e2e/app/routes/Table/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ export default function Resizing() {

const virtualizedData = React.useMemo(() => {
const size = oneRow ? 1 : 100000;
if (empty) {
return [];
}
const arr = new Array(size);
if (!empty) {
for (let i = 0; i < size; ++i) {
arr[i] = {
index: i,
name: `Name${i}`,
description: `Description${i}`,
id: i,
};
}
for (let i = 0; i < size; ++i) {
arr[i] = {
index: i,
name: `Name${i}`,
description: `Description${i}`,
id: i,
};
}
return arr;
}, [oneRow, empty]);
Expand Down
4 changes: 4 additions & 0 deletions testing/e2e/app/routes/Table/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,11 @@ test.describe('Virtual Scroll Tests', () => {
}); //Need to wait until the virtual rows are able to be rendered for the tests to work.

const rows = page.getByRole('rowgroup').getByRole('row');
const emptyContent = page.getByRole('rowgroup').getByText('No Data.');
expect((await rows.all()).length).toBe(0);

//Checks empty content to make sure it appears correctly.
await expect(emptyContent).toBeInViewport();
});

test('virtualized table should scroll to provided row', async ({ page }) => {
Expand Down

0 comments on commit 35dcd4f

Please sign in to comment.