i have some difficulty determining the best approach(in terms of UX) to this problem:
I have a list of elements on a page. Each element has an id and an orderNumber, that are fetched from the server.
var els = [
{id: '435', orderNumber: 1}
{id: '985', orderNumber: 2}
{id: '743', orderNumber: 3}
];
I need to be able to sort those items, using drag-n-drop. I've decided, that the best approach to reordering would be replacing the orderNumber for both items. So if i reorder 1st and 3rd items from the previous example, i'd get:
var els = [
{id: '743', orderNumber: 1}
{id: '985', orderNumber: 2}
{id: '435', orderNumber: 3}
];
So i could send the request to the server and update the UI optimistically, by reordering those items.
But what if the user wants to reorder other items in quick succession? On each drag-n-drop action i'll have to send all visible items. So if there are 50 items on the page, i have to send all 50, to be able to cancel all requests, but the last one, to avoid conflicts. That's very inefficient.
Or i could use debounce. Then i'll have to send only the items, that changed order, but UX would be terrible, if the server responds with an error or the request times out. Say the user reordered 10 items, then he gets the error and the UI gets restored to it's original state. It would be very frustrating.
To sum up both approaches:
Send all items on each drag-n-drop
- '+' On error we revert only 1 step behind
- '-' Huge overhead for each request(only change 2, send 50)
- '-' Multiple requests
Send only changed items after some delay
- '+' Only 1 request, no overhead. Only changed items get sent.
- '-' User might reorder 20 items out of 50, so we revert 10 steps behind on server/network error. Very frustrating for the user.
I have to add, that there is no 'Save' button, unfortunately. I might speak to designers/Product managers about it, but i doubt they'll go with it.
Are there any other ways of doing it?