Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

123
Visualizações
Losing scroll position in DOM-element after sorting array elements

Problem: After sorting the array elements, the scroll position is lost. An interesting fact is that the position of those elements that were moved to the end of the array is lost.

Question: How not to lose the scroll position when sorting an array of elements?

Steps To Reproduce:

  1. Change the scroll position for each DOM element.
  2. Press "btn reverse" button.

The current behavior: The first element saves the scroll position. The second and third elements reset the scroll position.

The expected behavior: All elements must retain their scroll position.

Example code (to scroll all DOM-elements and press "btn reverse"): https://stackblitz.com/edit/react-d2raex?file=src%2FApp.js

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

With the keys you're using, you're asking the List component to render the same DOM nodes but in different places. It has to remove them to do that. The DOM Element interface doesn't provide any API to reorder elements.

Original discussion here: https://github.com/facebook/react/issues/24640

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda