virtualizer.getVirtualItems() mismatches with number provided in count attribute during initialisation
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Bug
- Clareza
- Precisa de esclarecimento
- Status de atividade
- Estagnada
- Stack de tecnologia
- react, typescript
- Domínio
- frontend
Direção de pesquisa
Comece pela configuração de useVirtualizer e rastreie como count, getVirtualItems() e getTotalSize() respondem quando as props mudam. É necessário um exemplo reproduzível antes de comparar a contagem de itens informada com o comportamento esperado da virtualização; considera-se concluído quando a discrepância é explicada ou corrigida e o resultado esperado é demonstrado.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 7.2k
- Forks
- 495
- Merge médio
- 15h 11min
- PRs com merge (30d)
- 17
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TanStack/virtual
-
Document the indexAttribute option and cover it with a testTalvez já em andamento @officialasishkumar assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
Mantenedores costumam responder em até 1 dia
-
With `useScrollendEvent`, scrollToIndex and scrollToEnd stop short when the target moves while they settleTalvez já em andamento @Darkatse assumiu há 11 dias. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
Mantenedores costumam responder em até 1 dia
-
svelte-virtual renders no rows when the scroll element is bound after the store subscribesTalvez já em andamento @clean99 assumiu há 15 dias. Aberta
Dificuldade 4/5 1-2 dias Facilidade para iniciantes 35/100
Mantenedores costumam responder em até 1 dia
-
anchorTo: 'end' does not keep the reading position when only paddingStart changesTalvez já em andamento @duongynhi000001-crypto assumiu há 15 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 30/100
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/virtual
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
fb55/htmlparser2#2579 ·
Mantenedores costumam responder em até 1 dia
-
bug good first issue needs-review
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 83/100
Mantenedores costumam responder em até 1 dia
-
Add Module DB RulesAbertadocumentation public
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 68/100
midnightntwrk/umbradb#65 ·
Mantenedores costumam responder em até 2 dias
-
area/channels kind/bug priority/medium
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
nanocoai/nanoclaw#4501 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
needs verification
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 13 dias