Technical document

Data Design for Drag & Drop Sorting and Image Management

When managing image order with React's drag & drop UI, we organize how to handle order values, concurrent updates, save timing, and accessibility.
UI Design / Image Management~10 minPublication Date September 22, 2026Update date September 22, 2026
Data Design for Drag & Drop Sorting and Image Management

Summary

Key points of this document

  • Where are the design challenges?
  • How to define boundaries?
  • Details that matter in implementation

Overview

Image sorting UI seems simple, but the order breaks if save timing and concurrent updates are not considered. Both UI comfort and data consistency must be addressed. Drag & drop sorting appears to be a UI problem, but it's a data design problem involving concurrent editing, order persistence, and image processing failures.

Where are the design challenges?

In a UI that reorders an image list by dragging, it's common to save the array order directly from the frontend. However, it's not simple when considering updates by other users, image deletion, order immediately after upload, and save failures.

Image files are in storage, and metadata is in the DB. Sorting is a metadata update, not a file movement. Also, alternative operations must be considered for users who find drag operations difficult.

In an image management screen, even if it just looks like reordering uploaded images, edits by multiple users, processing thumbnails, deleted images, and pre-save order get mixed. If only the on-screen array is treated as truth, update conflicts will break the order.

How to define boundaries?

The DB should hold image ID, owner target ID, display order, status, and update time. On the React side, the order during dragging is treated as a temporary state, and an array of image IDs is sent to the API upon saving. The API checks if the set of target images has changed.

In design, we separate the image itself, display metadata, order, and processing status. Even if UI operations are implemented with dnd-kit, what's sent to the API is not the entire array, but the moved item and its relative position, or the updated sort_key.

Details that matter in implementation

When using dnd-kit, update the temporary order at the end of dragging and send it to the API via a save button or auto-save. The API re-numbers the order within a transaction and rejects non-existent image IDs or unauthorized images.

On the Laravel side, the images table should have status, sortkey, storagekey, and checksum. The React side separates the temporary order during dragging from the saved order, allowing rollback upon save failure.

  • Sequential positions lead to a wide update range for insertions or large-scale reordering, so consider a sort_key with gaps.
  • Immediately after upload, display as 'processing' status, and change to 'available' after thumbnail generation is complete.
  • Deletion should be logical deletion, not immediate physical deletion, considering reference checks and undo options.

Observing failure modes

Validation checks for save failures after reordering, deletion by other users, order immediately after image addition, keyboard operations, and mobile operations. E2E tests ensure the order is maintained after reloading.

Validation checks for continuous dragging, save failures, simultaneous reordering by other users, and moving images that are still processing. API tests reject non-existent image IDs or unauthorized images mixed into the reordering target.

Discarded options and tradeoffs

Auto-save offers light operation but makes explaining communication failures difficult. The save button method is clear but increases steps. Choosing based on business importance and frequency of use is realistic.

Immediate reflection in the UI improves user experience but requires recovery upon save failure. Not reflecting until save completion is safer but makes the operation feel heavy. If using optimistic updates, the design must always retain differences and the original state.

Practical Decision-Making Principles

Sorting UI is not just about visual operation; it's crucial how to persist the order and protect it during conflicts. Separating UI state from saved state leads to manageable and robust image management.

Image reordering is an area where a pleasant UI and robust order management must be considered simultaneously. Separating the on-screen array from the DB order makes it resilient to concurrent editing and failures.

Technical documents

We will continue to increase technical documentation.

We will continue to organize our thoughts on AI, cloud, business app development, requirements definition, and operational design into documents.

Go to technical documentation list