Measurements of virtual items don't get re-calculated when lanes are changed (with `measureElement`)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/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
Hướng nghiên cứu
Bắt đầu với trường hợp tái hiện trong packages/example và cấu hình useWindowVirtualizer được mô tả trong issue. Theo dõi cách getVirtualItems() xử lý các phép đo của measureElement khi giá trị lanes thay đổi. Được xem là hoàn thành khi tất cả các mục ảo trong phạm vi được đo lại sau khi lanes thay đổi, không có mục nào giữ một lane không hợp lệ và layout không bị hỏng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
There is a similar issue here: #1036
When using measureElement with useVirtualizer, changing the number of lanes dynamically causes the layout to break.
In my case, some of the virtual items returned by getVirtualItems() still have the old measurements as they don't get re-calculated. For example if I change lanes to a smaller number, some items still have the old larger lane, causing layout to break.
My debugging suggests the problem might be the minimum pendingMeasuredCacheIndexes, it wrongly skipped some of the items that should be visible, so their measurements are not re-calcualted.
Your minimal, reproducible example
https://github.com/hmpthz/another-react-responsive-masonry/tree/main/packages/example
Steps to reproduce
I actually created a repo trying to showcase and solve this. You can see the example above. Basically, the problem happens like this:
const { currentBreakpoint } = useBreakpoint(breakpointColumns);
const lanes = currentBreakpoint.nCol; // changing lanes dynamically
const rowVirtualizer = useWindowVirtualizer({
lanes: currentBreakpoint.nCol,
...others
});
const virtualItems = rowVirtualizer.getVirtualItems();
const columns = useMemo(() => {
const arr = Array.from({ length: lanes }, () => [] as VirtualItem[]);
for (const item of virtualItems) {
arr[item.lane].push(item); // you'll get error as lane is out of bound
}
return arr;
}, [virtualItems, lanes]);
Expected behavior
The measurements of all virtual items in the range get correctly re-calculated
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Any platform
tanstack-virtual version
v3.13.12
TypeScript version
v5.9.3
Additional context
While trying to solve this problem, I made significant changes to the sourcecode that I feel like might not be suitable for a PR to the original repo, so eventually I create a new one: https://github.com/hmpthz/another-react-responsive-masonry
I wonder if you have plan to solve this issue?
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.1k
- Fork
- 472
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 12
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
-
measureElement caches 0 size for nodes that aren't attached yet (Vue: rows stack at start 0 and the list scrolls away on mount)Có thể đã có người làm @webn00b đã nhận 10 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`scrollToIndex(last, { align: 'end' })` stays short of the end after a measured row grows (virtual-core ≥ 3.17.0)Có thể đã có người làm @minwookshin đã 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 55/100
TanStack/virtual#1290 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
virtual-core: desktop Safari drops the prepend anchor write when history lands during the top rubber-band bounceCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
marko-virtual: scrollToEnd during an in-flight prepend strands the view one prepend above the bottom (chat-pretext e2e fails on CI)Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 4/5 3-5 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
Tất cả issue của TanStack/virtual
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
wardian-app/Wardian#1603 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Sign the pledgeĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
input-output-hk/devx-updates#168 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
github/docs#46222 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent-ready area: config area: skills type: chore upstream: brain-kit
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
-
dev experience frontend good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
cuttle-cards/cuttle#1403 ·
Maintainer thường phản hồi trong vòng 1 ngày