FrontendInterviews.dev

Loading problem…

129. Data Table - Inline Editing

Hard•
Acceptance: 31.00%
•
🔓3/3 Pro unlocks today

This problem builds on data-table. Complete that first, then load your solution to continue.

Build a production-ready Data Table component that extends the base Data Table with inline editing functionality. This builds on top of the sorting feature from the base Data Table.

Requirements

1. Inline Editing

  • Click on cell to edit
  • Input field appears for editing
  • Save changes on Enter or blur
  • Cancel editing on Escape
  • Visual feedback for edited cells
  • Validation (optional)

2. Data Structure

interface Column {
  key: string;
  label: string;
  sortable?: boolean;
  editable?: boolean;
}

interface DataTableProps {
  data: Record<string, any>[];
  columns: Column[];
  onDataChange?: (rowIndex: number, columnKey: string, value: any) => void;
}

Example Usage

<DataTable 
  data={data} 
  columns={columns}
  onDataChange={(rowIndex, columnKey, value) => {
    // Handle data update
  }}
/>

Constraints

  • Maintain sorting functionality from base Data Table
  • Handle editing state properly
  • Update data immutably