Overview
At Zepto, efficiency in data management is crucial for various internal operations, from inventory tracking to financial reporting. We often need simple, interactive tools to quickly view and modify structured data. This problem focuses on building a fundamental component for such tools: an interactive spreadsheet cell grid that allows users to view and edit cell contents one at a time.
What you need to do / Task
Your primary task is to create a React component that renders a static grid of spreadsheet cells. This component should allow users to view the initial cell contents and then edit them individually.
- Render a Grid: Display a 5x5 grid of cells. Each cell should initially show some predefined content (e.g., "Cell A1", "Cell B2", etc., or simple numbers).
- Single Cell Editing: When a user clicks on any cell, it should transition into an editable state. This means the cell's content should be replaced by an input field, pre-filled with the current cell's value.
- Save on Enter: When the user is editing a cell and presses the
Enter key, the new value from the input field should be saved, and the cell should revert to its display-only state, showing the updated content.
- Save on Blur: If the user clicks outside the currently edited cell (or the input field loses focus for any other reason), the new value should also be saved, and the cell should revert to its display-only state.
- Exclusive Editing: Ensure that only one cell can be in an editable state at any given time.
UI/UX expectations
- The grid should be clearly laid out, resembling a simple spreadsheet.
- Cells should have visible borders.
- When a cell is in edit mode, the input field should be clearly visible and allow text entry.
- The transition between display and edit mode should be smooth.
- The overall layout should be responsive enough for basic desktop use.
Acceptance criteria
- A 5x5 grid of cells is rendered on the screen.
- Each cell initially displays its predefined content.
- Clicking a cell makes it editable, showing an input field with its current value.
- Pressing
Enter while editing a cell saves the new value and exits edit mode.
- Clicking outside the active input field (blur) saves the new value and exits edit mode.
- Only one cell can be in edit mode at any given time.
- The updated cell content is displayed correctly after saving.