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

Make one or more item inside the list fixed/locked #97

Open
ahmaadaziz opened this issue Aug 21, 2023 · 6 comments
Open

Make one or more item inside the list fixed/locked #97

ahmaadaziz opened this issue Aug 21, 2023 · 6 comments

Comments

@ahmaadaziz
Copy link

ahmaadaziz commented Aug 21, 2023

I am looking for a way to make a specific item inside a list to be not draggable which is implemented using the disabled property. But the items that are not disabled can still be dragged above it and that would change the order of the list; the feature I am looking for would FIX that item's index so its order cannot be changed.

For example I have a list that contains 5 items and I want the first item to always remain on top, so I will FIX that item and make it disabled, so now all other items below it can be dragged and moved around but that FIXED item will always remain at index 1/0. Same could be done for the last item as well.

@ahmaadaziz ahmaadaziz changed the title Make one or more item inside the list fixed Make one or more item inside the list fixed/locked Aug 21, 2023
@IanVS
Copy link
Contributor

IanVS commented Dec 21, 2023

Just a thought, but could you add the first/last items as part of the renderList prop, instead of adding them to renderItem?

@ahmaadaziz
Copy link
Author

@IanVS consider I want to fix the 4th item in my list then then it won't work. I only provided an example for better understanding but it doesn't necessary always have to be the first and last items

@IanVS
Copy link
Contributor

IanVS commented Dec 22, 2023

In that case, it seems like you could have two lists, one above the fixed item, and one below.

@ahmaadaziz
Copy link
Author

ahmaadaziz commented Dec 22, 2023

@IanVS Yes you are right, I can do that and in case of dynamically selecting the fixed item i can maintain two lists and filter out the fixed item, but in case there is more than one fixed item the amount of preprocessing that I have to do can be a bit much.

Imagine a case where the 2nd, 5th, 9th and 17th (these are random by the way) items need to stay fixed and I only get to know those indexes right before render from a some fetched data. Splitting and maintaining multiple lists and rendering them above and below those fixed items is definitely not the best solution (Hopefully this gets my point across 🤞)

My problem has already been solved due to architectural changes (the issue can be closed 👍), however I feel like this is something the library should handle by itself.

Consider it a feature request now 🚀

@IanVS
Copy link
Contributor

IanVS commented Dec 22, 2023

Yeah I understand it's not an ideal workaround, but I wonder what kind of use case would involve so many "locked" cells requiring sorting only above or below them. I'd be curious to hear what kind of UI you're building where this might be needed. (note: I'm not a maintainer, just trying to help out)

@ahmaadaziz
Copy link
Author

ahmaadaziz commented Dec 22, 2023

haha @IanVS your curiosity is understandable for such a situation (which by the way I am not in any more 😉). My UI consisted of a list where the end user can add as many items as they want from an available list type of items and in those items, some had to be fixed, so this was merely an edge case for me. Thanks for taking the time and interest, your help is appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants