virtualizer.getVirtualItems() mismatches with number provided in count attribute during initialisation
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 25/100
- Issue 類型
- 缺陷
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- react, typescript
- 領域
- frontend
研究方向
從 useVirtualizer 設定開始,追蹤 props 變更時 count、getVirtualItems() 和 getTotalSize() 的回應方式。在將回報的項目數量與預期的虛擬化行為進行比較之前,需要一個可重現的範例;當差異獲得解釋或修正,且預期結果獲得示範時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Describe the bug
On Re-Render the number returned by virtualizer.getVirtualItems() is different than the number provided during initialisation of the virtualiser.
Initialising Virtualiser
const count = props.attributeGroups.length;
const parentRef = React.useRef<HTMLDivElement>(null);
const virtualizer = useVirtualizer({
count,
getScrollElement: () => parentRef.current,
estimateSize: index => {
const group = props.attributeGroups[index];
let size = VIRTUALISED_ATTRIBUTE_GROUP_DEFAULT_SIZE;
if (group) {
size =
group.attributes.length * VIRTUALISED_ATTRIBUTE_ELEMENT_DEFAULT_SIZE;
}
return size;
},
onChange: props.handleNavBarChangeOnScroll
});
const items = virtualizer.getVirtualItems();
const totalSize = virtualizer.getTotalSize();
return (
<div ref={parentRef}>
<div id={`${props.currentMenu.name}-attributeGroupsContainer`} style={{ height: `${totalSize}px` }}>
{items.map(virtualItem => (
<div
key={virtualItem.key}
data-index={virtualItem.index}
ref={virtualizer.measureElement}
style={{
position: "relative",
width: "100%",
}}
>
<GroupContainer
{...props}
key={props.attributeGroups[virtualItem.index].name}
group={props.attributeGroups[virtualItem.index]}
/>
</div>
))}
</div>
</div>
);
Obeserved : In the above code with console.log(), items.length and count are different (items.length is 8 whereas count is 21) for some reason when props change but the totalSize however is computed for 21 components (more than required) due to which there is a empty section on the page.
Expected: Both items.length and count should be the same. (Please correct me if I am wrong in assuming this)
Regards,
Abhishek
Your minimal, reproducible example
NA
Steps to reproduce
NA
Expected behavior
Obeserved : In the above code with console.log(), items.length and count are different (items.length is 8 whereas count is 21) for some reason when props change but the totalSize however is computed for 21 components (more than required) due to which there is a empty section on the page.
Expected: Both items.length and count should be the same. (Please correct me if I am wrong in assuming this)
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
Chrome, Mozilla
tanstack-virtual version
3.0.0-beta.54
TypeScript version
4.9.5
Additional context
No response
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.
- 主要語言
- TypeScript
- 星號
- 7.2k
- 分支
- 495
- 平均合併
- 15 小時 11 分鐘
- 30 天內合併 PR
- 17
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
TanStack/virtual 的其他 Issue
-
Document the indexAttribute option and cover it with a test可能已有人在做 @officialasishkumar 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 55/100
維護者通常 1 天內回覆
-
With `useScrollendEvent`, scrollToIndex and scrollToEnd stop short when the target moves while they settle可能已有人在做 @Darkatse 於 11 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 25/100
維護者通常 1 天內回覆
-
svelte-virtual renders no rows when the scroll element is bound after the store subscribes可能已有人在做 @clean99 於 15 天前認領。 未關閉
難度 4/5 1-2 天 新手友好度 35/100
維護者通常 1 天內回覆
-
anchorTo: 'end' does not keep the reading position when only paddingStart changes可能已有人在做 @duongynhi000001-crypto 於 15 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 30/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
fb55/htmlparser2#2579 ·
維護者通常 1 天內回覆
-
bug good first issue needs-review
難度 1/5 1-3 小時 新手友好度 83/100
維護者通常 1 天內回覆
-
documentation public
難度 1/5 1-3 小時 新手友好度 68/100
midnightntwrk/umbradb#65 ·
維護者通常 2 天內回覆
-
area/channels kind/bug priority/medium
難度 2/5 1-3 小時 新手友好度 78/100
nanocoai/nanoclaw#4501 · 1 則留言 ·
維護者通常 1 天內回覆
-
needs verification
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 13 天內回覆