question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] undo prepend(shift from array) cause visible position change

See original GitHub issue

Describe the bug prepending to items using firstItemIndex maintain the visible position, but undo prepending cause the visible position change. (items move up because of above items removed)

Reproduction Edit sandpack-project (forked)

To Reproduce Steps to reproduce the behavior:

  1. go to the sandbox
  2. click ‘prepend’: it’s okay.
  3. click ‘unprepend’: visible position change.

Expected behavior click ‘unprepend’: visible position maintain.

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Chrome

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
petyosicommented, Mar 5, 2022

Should be fixed in e861fe9acea5b2cbb425b35b2fac75aaff8c0c13

0reactions
rhinoccommented, Mar 2, 2022

I’m having the exact same issue. In my case I have need to add and remove items above the visible position area without any jump.

This is a workaround, I use scrollTo to adjust scroll position after deleting items. it seems works but I suspect it may cause some flash effect (i.e. items moving up and down) when things got complicated. And it will also be painful if the row height is changeable. https://codesandbox.io/s/sandpack-project-forked-ikdle3?file=/App.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove Object from Array using JavaScript - Stack Overflow
You can use several methods to remove item(s) from an Array: //1 someArray.shift(); // first element removed //2 someArray = someArray.slice(1); // first ......
Read more >
Array.prototype.shift() - JavaScript - MDN Web Docs
The shift() method removes the first element from an array and returns that removed element. This method changes the length of the array....
Read more >
5. Working with Arrays and Loops - JavaScript Cookbook [Book]
An array is an ordered collection of elements. In JavaScript, an array can be created using formal object notation, or it can be...
Read more >
Observable Arrays - Knockout.js
shift () — Removes the first value from the array and returns it. reverse() — Reverses the order of the array and returns...
Read more >
Excel Error Cannot Shift Objects Off Sheet - Contextures
How to fix Excel error, Cannot Shift Objects Off Sheet or Can't push objects off sheet. Simple shortcut, or make small change to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found