clauderic / clauderic/react-sortable-hoc

is it possible to filter elements but keep indexes?

Open
#690 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
10.9k
Forks
959
PR merge metrics
No merged PRs in 30d

Description

let's say I have a list of items to sort: [A, B, C, D]

**Step 1**
I grab B and move to first position: [B, A, C, D] `oldIndex = 1, newIndex = 0`

**Step 2**
Now I want to filter and only display all elements different than A: [B, (A was here), C, D]

**Step 3**
Then move D to first position: [D, B, (A was here), C] `oldIndex = 2, newIndex = 0`

How can I keep the indexes taking into account that A is in the list but not rendered?
I would like to have in **Step 3** `oldIndex = 3, newIndex = 0`

Thanks!

**Edit**: the array can potentially grow to tenths/hundreds of items and only be rendered a few (10 to 30 aprox)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.