Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] There is bug when deleting multiple items from array #61

Open
akrv7591 opened this issue Jul 2, 2024 · 0 comments
Open

[BUG] There is bug when deleting multiple items from array #61

akrv7591 opened this issue Jul 2, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@akrv7591
Copy link

akrv7591 commented Jul 2, 2024

It seems there is bug in applyChangesToArray function when deleting multiple items.
In applyChangesToArray function to apply changes array it is being sorted on index field on ASC order then with reduce function it is applying changes to it.
The bug is happening when removing element from array revisedArray.splice(index, 1).
Let's say we have array with length of 5 and we want to delete 5 elements from array. On every iteration index is going up and the size of array is going down, by the time you are deleting element with index 3 revisedArray length is 2 then it cant remove any element. at the end it returns remaining 2 elements.
I have extracted applyChangesToArray function logic from code. You can try it in typescrip playground. Code is provided below

@akrv7591 akrv7591 added the bug Something isn't working label Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants