Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!