No rows returned by useVirtualizer in unit tests
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend, testing-qa
Hướng nghiên cứu
Bắt đầu bằng cách chạy bài kiểm thử đơn vị React được cung cấp và so sánh hành vi giữa v3.0.0-beta.62 và v3.0.1. Kiểm tra đường dẫn useVirtualizer và các thay đổi được tham chiếu trong pull request #598; hoàn thành khi getVirtualItems() chứa các hàng mong đợi và bài kiểm thử render cả hai tên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
In browser table rows are rendered as expected. In unit tests useVirtualizer returns an empty array from rowVirtualizer.getVirtualItems(). The bug is introduce with changes introduced by v3.0.0-beta.63. It also exists in the latest release v3.0.1
I think it was introduced by #598 here
Your minimal, reproducible example
below
Steps to reproduce
This unit test will pass for v3.0.0-beta.62 and fail for any version there after.
import { useVirtualizer } from "@tanstack/react-virtual";
import { render, screen } from "@testing-library/react";
import { styled } from "@mui/material";
import { useCallback, useRef } from "react";
const items = [
{ id: 1, name: "foo" },
{ id: 2, name: "bar" },
];
const Parent = styled("div")({ height: "100%", width: "100%", overflow: "auto" });
const Inner = styled("div")({ width: "100%", position: "relative" });
const Row = styled("div")({ position: "absolute", top: 0, left: 0, width: "100%" });
function VirtualTableComponent() {
const parentRef = useRef<HTMLDivElement>(null);
const rowVirtualizer = useVirtualizer({
count: items.length,
getScrollElement: () => parentRef.current,
estimateSize: useCallback(() => 56, []),
});
return (
<Parent ref={parentRef}>
<Inner sx={{ height: `${rowVirtualizer.getTotalSize()}px` }}> {/* set at 112px as expected */}
{rowVirtualizer.getVirtualItems().map((virtualRow) => ( // always an empty array
<Row
key={virtualRow.index}
data-index={virtualRow.index}
ref={rowVirtualizer.measureElement}
style={{ transform: `translateY(${virtualRow.start}px)` }}
>
<div>{items[virtualRow.index].name}</div>
</Row>
))}
</Inner>
</Parent>
);
}
describe("@tanstack/react-virtual", () => {
it("renders rows", () => {
render(<VirtualTableComponent />);
expect(screen.getByText(items[0].name)).toBeInTheDocument();
expect(screen.getByText(items[1].name)).toBeInTheDocument();
});
});
Expected behavior
As a user I expect the provided unit test to pass but it fails.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
macOS
tanstack-virtual version
v3.0.1
TypeScript version
v4.9.5
Additional context
I've console.log'd out the value of rowVirtualizer.getTotalSize() and it is given 112 as expected
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
- Ngôn ngữ chính
- TypeScript
- Star
- 7.2k
- Fork
- 495
- Merge trung bình
- 23 giờ 16 phút
- Pull request đã merge (30 ngày)
- 19
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/virtual
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 1 ngày
-
With `useScrollendEvent`, scrollToIndex and scrollToEnd stop short when the target moves while they settleCó thể đã có người làm @Darkatse đã nhận 8 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
svelte-virtual renders no rows when the scroll element is bound after the store subscribesCó thể đã có người làm @clean99 đã nhận 13 ngày trước. Đang mở
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
anchorTo: 'end' does not keep the reading position when only paddingStart changesCó thể đã có người làm @duongynhi000001-crypto đã nhận 13 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
Maintainer thường phản hồi trong vòng 1 ngày
-
anchorTo: 'end' loses the end when the scroll element shrinksCó thể đã có người làm @langleyd đã nhận 41 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TanStack/virtual
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
hemilabs/ui-monorepo#2711 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
code-yeongyu/senpi#6929 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
lingdojo/kana-dojo#34261 · 1 bình luận · 5 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
embedpdf/embed-pdf-viewer#1116 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Revise communication normsĐang mởcurrent task
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Sunday-School-Software/Sunday-School-Scheduler#87 ·
Maintainer thường phản hồi trong vòng 1 ngày