Frontend School

Build an Editable Spreadsheet Cell Grid

Machine Coding
easy

Build an Editable Spreadsheet Cell Grid

Easy
Frontend
React
UI
Spreadsheet

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.

  1. 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).
  2. 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.
  3. 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.
  4. 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.
  5. 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.

Constraints

Constraints & assumptions

  • The grid size is fixed at 5 rows and 5 columns.
  • Initial cell data can be simple strings or numbers, hardcoded within the component.
  • The application will run in a modern browser environment (Chrome, Firefox, Safari).
  • You should use React for building the component.
  • No external UI libraries are allowed; use plain CSS or styled components if preferred.
  • Focus on functional correctness and clean component structure.

Out of scope

  • Implementing complex spreadsheet features like formulas, undo/redo, multi-cell selection, copy/paste, or dynamic row/column addition.
  • Server-side persistence or API integration.
  • Advanced accessibility features beyond basic semantic HTML for inputs.

What interviewers evaluate

  • Correctness and Completeness: Does the solution meet all acceptance criteria and handle edge cases for cell editing?
  • React Fundamentals: Proper use of React state, props, and lifecycle/hooks for managing component behavior.
  • Code Structure & Readability: Clean, modular, and well-organized code with appropriate component separation (if any).
  • UI/UX Implementation: Effective use of CSS for layout and visual feedback during interactions.

Loading editor...