[Bug] Virtual scrollbar overlaps the content instead of reserving a gutter
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
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Start in src/ScrollBar.tsx and trace how the scrollbar is rendered alongside the holder and positioned against the list root. Compare the vertical and horizontal cases, including right-to-left positioning, and check existing scrollbar and layout tests. Done means virtual scrollbars no longer overlap the content or last row, with spacing preserved in both directions.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Related antd issues (this was found while working on antd's Listy):
- ant-design/ant-design#59641 — spacing between the content and the virtual scrollbar
- ant-design/ant-design#59633 — the virtual scrollbar thumb colour falling back to
rgba(0, 0, 0, 0.5)
What problem does this feature solve?
In virtual mode the custom scrollbar is absolutely positioned at the right edge of the list root and does not reserve any space, so the content underneath it gets covered.
Concrete case — antd Listy:
- The row breathing room lives on the item itself:
.ant-listy-item { padding: 12px 16px }— that 16px right padding is what separates the row content from the list edge. - The vertical scrollbar is 8px wide and sits at
right: 0of the list root. - Net effect: the scrollbar covers the rightmost 8px of that 16px padding, so the gap between the content and the scrollbar is 8px instead of 16px — and unlike a native overlay scrollbar this one is always visible, so the halved spacing is permanent.
Measured (antd 6.6.7, Chrome 155, macOS 26.7), list width 320px:
| mode | item right padding | content box right edge | scrollbar left edge | content → scrollbar |
|---|---|---|---|---|
virtual |
16px | 336px | 344px | 8px |
| non-virtual | 16px | 336px | 352px | 16px |
Same component, same items, same width — only the spacing differs because of the virtual switch.
Repro: https://codesandbox.io/p/devbox/k3g67m?file=%2Findex.tsx — two <Listy> side by side, the top one with virtual, the bottom one without.
What does the expected behavior look like?
The scrollbar should not sit on top of the content. Either:
- reserve a gutter for it (e.g.
scrollbar-gutter: stable, or add the scrollbar width to the content box), or - behave like a native overlay scrollbar (visible on hover / while scrolling only).
At minimum the distance between the content and the scrollbar should not change when toggling virtual.
Where the code lives
src/ScrollBar.tsx:
const containerStyle = {
position: 'absolute',
visibility: visible ? null : 'hidden',
};
// vertical
Object.assign(containerStyle, {
width: 8,
top: 0,
bottom: 0,
[isLTR ? 'right' : 'left']: 0,
});
The scrollbar is rendered as a sibling of the holder and positioned against the list root, so the content box is never inset by the scrollbar width.
Additional notes
- The horizontal scrollbar has the same problem in the other direction (
height: 8; bottom: 0) — it covers the bottom padding of the last visible row. - The thumb colour falls back to
rgba(0, 0, 0, 0.5)here (var(--rc-virtual-list-scrollbar-bg, rgba(0, 0, 0, 0.5))); consumers currently have to override that variable themselves, e.g. antd does it per component (see ant-design/ant-design#59633). - Consumers also work around the overlap themselves — e.g. antd's
Treeaddspadding-rightto its list to keep the row highlight clear of the capsule scrollbar. Handling it once here would be better for every consumer.
Environment
- @rc-component/virtual-list: 1.5.2
- antd: 6.6.7 (the consumer used for the measurements above)
- Chrome 155.0.8059.85 / macOS 26.7.1
- Ngôn ngữ chính
- TypeScript
- Star
- 812
- Fork
- 171
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 react-component/virtual-list
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 58/100
react-component/virtual-list#325 · 1 bình luận ·
-
渲染第一项高度变更,滚动位置不准确Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
react-component/virtual-list#303 ·
-
希望添加横向虚拟滚动Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
react-component/virtual-list#297 ·
-
嵌套滚动内容时,内部滚动效果会直接穿透到外层虚拟列表不生效Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
react-component/virtual-list#292 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
react-component/virtual-list#290 · 1 bình luận ·
Tất cả issue của react-component/virtual-list
Issue tương tự
-
Manager flashes an empty "errorOccurred" dialog while redirecting a logged-out user to loginĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
openremote/openremote#3487 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
coollabsio/jean#867 ·
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
ehmpathy/rhachet-roles-bhuild#616 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
📘 Docs supabase/cli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(cli): theme file home-directory check uses startsWith (sibling dirs pass, Windows casing fails)Đang mởarea/core kind/bug priority/p2 status/bot-triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
google-gemini/gemini-cli#29955 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày