Overview
At Browserstack, managing test cases, test runs, or even simple project tasks often involves lists of items that need flexible organization. The ability to reorder items intuitively via drag-and-drop is a fundamental UI pattern that significantly enhances user experience and productivity. This problem challenges you to implement a basic drag-and-drop reordering feature for a list of tasks, simulating a common interaction found in many of our products.
What you need to do / Task
Your goal is to build a simple React component that displays a list of tasks. Users should be able to reorder these tasks by dragging an item and dropping it into a new position within the list.
- Render a list of tasks: Display a predefined set of tasks as a vertical list.
- Enable Dragging: Make each task item draggable.
- Enable Dropping and Reordering: Allow users to drop a dragged task item into a new position in the list, effectively reordering the tasks. The list should visually update to reflect the new order.
UI/UX expectations
- Clear Items: Each task item should be clearly distinguishable (e.g., with a border or background).
- Drag Feedback: When an item is being dragged, it should provide visual feedback (e.g., a semi-transparent ghost image or a temporary border/shadow around the dragged item).
- Drop Target Feedback: As a dragged item hovers over potential drop locations, there should be visual cues indicating where the item will be placed (e.g., a gap appearing, or a border highlighting the insertion point).
- Smooth Reorder: The list should update smoothly to reflect the new order without jarring jumps.
Acceptance criteria
- The initial list of tasks renders correctly.
- Any task item can be picked up and dragged.
- A dragged task item can be dropped at any valid position (start, middle, or end) within the list.
- Upon a successful drop, the list items are reordered according to the drop position.
- The UI updates immediately to show the new order of tasks.
- No console errors occur during drag-and-drop operations.