virtualizer.getVirtualItems() mismatches with number provided in count attribute during initialisation
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- react, typescript
- Área
- frontend
Línea de trabajo
Comienza en la configuración de useVirtualizer y rastrea cómo responden count, getVirtualItems() y getTotalSize() cuando cambian las props. Se necesita un ejemplo reproducible antes de comparar el recuento de elementos indicado con el comportamiento esperado de la virtualización; se considera terminado cuando la discrepancia está explicada o corregida y se demuestra el resultado esperado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 7.2k
- Forks
- 495
- Merge medio
- 15 h 11 min
- PR fusionados (30 d)
- 17
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/virtual
-
Document the indexAttribute option and cover it with a testPosiblemente ocupada @officialasishkumar la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 1 día
-
With `useScrollendEvent`, scrollToIndex and scrollToEnd stop short when the target moves while they settlePosiblemente ocupada @Darkatse la tomó hace 11 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
-
svelte-virtual renders no rows when the scroll element is bound after the store subscribesPosiblemente ocupada @clean99 la tomó hace 15 días. Abierto
Dificultad 4/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
anchorTo: 'end' does not keep the reading position when only paddingStart changesPosiblemente ocupada @duongynhi000001-crypto la tomó hace 15 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 30/100
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/virtual
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
fb55/htmlparser2#2579 ·
Los mantenedores suelen responder en 1 día
-
bug good first issue needs-review
Dificultad 1/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
Add Module DB RulesAbiertodocumentation public
Dificultad 1/5 1-3 horas Aptitud para principiantes 68/100
midnightntwrk/umbradb#65 ·
Los mantenedores suelen responder en 2 días
-
area/channels kind/bug priority/medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nanocoai/nanoclaw#4501 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Docker images: plain X.Y.Z tag (e.g. 7.2.3) is never updated after the initial release buildAbiertoneeds verification
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 13 días