Overview
At CRED, efficiency and organization are key. We're building a new feature for our internal task management system that allows users to easily prioritize their daily tasks. This problem focuses on implementing an intuitive drag-and-drop interface for reordering a list of tasks.
What you need to do / Task
Your goal is to build a React component that displays a list of tasks and allows users to reorder them using drag-and-drop interactions.
- Render a List of Tasks: Display an initial list of tasks, each with a title and a priority number.
- Implement Drag-and-Drop Reordering: Enable users to click, drag, and drop any task item to a new position within the list.
- Update Task Order: When a task is dropped, the underlying data array should be updated to reflect the new order, and the UI should immediately reflect this change.
- Visual Feedback: Provide clear visual cues during the drag-and-drop process, such as highlighting the dragged item and indicating the potential drop zone.
UI/UX expectations
- Layout: The tasks should be displayed as a vertical list. Each task item should be clearly distinguishable (e.g., with a border or background color).
- Interaction: A user should be able to drag any task item from its current position and drop it between any two other tasks, or at the beginning/end of the list.
- Drag Feedback: The item being dragged should have a distinct visual style (e.g., reduced opacity, different background).
- Drop Zone Feedback: As a dragged item hovers over another item's potential drop position, there should be a visual indicator (e.g., a border around the target area, or a gap opening up) to show where the item will be placed.
- Accessibility: Use semantic HTML elements where appropriate for list structures.
Acceptance criteria
- Users can successfully drag a task and drop it into a new position in the list.
- The visual order of tasks updates immediately and correctly after a drop.
- The internal state (array of tasks) accurately reflects the new order after a successful drag-and-drop operation.
- Dragging an item provides visual feedback (e.g., opacity change).
- Dropping an item between two existing items correctly inserts it without breaking the order of other items.
- No unexpected layout shifts or scroll jumps occur during the drag operation.