Skip to content

fix: match archive row color in form items table#814

Open
priscila-moneo wants to merge 1 commit intomasterfrom
fix/match-archive-row-color
Open

fix: match archive row color in form items table#814
priscila-moneo wants to merge 1 commit intomasterfrom
fix/match-archive-row-color

Conversation

@priscila-moneo
Copy link

@priscila-moneo priscila-moneo commented Mar 5, 2026

ref: https://app.clickup.com/t/86b859xzw

image

Summary by CodeRabbit

  • New Features

    • Per-cell inline editing in tables.
    • Option to mark rows as archived/disabled, preventing edits.
  • Improvements

    • Archived rows show distinct dimmed styling for clarity.
    • Archive/unarchive action remains active and visually preserved (not dimmed), so items can be toggled.
    • Deletion confirmation content is now customizable.

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

Adds per-cell editing to the editable table, centralizes archived-row cell styling via ARCHIVED_CELL_SX and helpers, introduces a disableProp option to mark rows as archived/disabled, updates pages to opt into disableProp, and extends tests with SX inspection and archived-style assertions.

Changes

Cohort / File(s) Summary
Table core & editable
src/components/mui/table/mui-table.js, src/components/mui/editable-table/mui-table-editable.js
Add ARCHIVED_CELL_SX, getArchivedCellSx, and getCellSx helpers; replace inline per-cell sx with computed getCellSx(row, baseSx); use stable row.id keys; introduce disableProp option handling. Editable table: add per-cell editing state/handlers and public props onCellChange, deleteDialogBody.
Tests
src/components/mui/__tests__/mui-table-editable.test.js
Add TableCell test shim exposing sx via data-sx, add getCellSx test helper to parse data-sx, switch sortDir to numeric, and add tests asserting archived styles applied to content/edit/delete cells and excluded from archive/unarchive action cell.
Pages: sponsor tables
src/pages/sponsors/sponsor-form-item-list-page/index.js, src/pages/sponsors/sponsor-forms-tab/components/manage-items/sponsor-forms-manage-items.js
Enable archived-row behavior by adding disableProp: "is_archived" to table options; update copyright years and minor formatting (trailing commas).

Sequence Diagram

sequenceDiagram
    actor User
    participant TableCell
    participant MuiTableEditable
    participant onCellChange

    User->>TableCell: Click cell to edit
    TableCell->>MuiTableEditable: handleCellClick(rowId, colKey)
    MuiTableEditable->>MuiTableEditable: set editingCell state
    MuiTableEditable->>TableCell: render input (edit mode)

    User->>TableCell: Change value and blur
    TableCell->>MuiTableEditable: handleCellBlur(rowId, colKey, newValue)
    MuiTableEditable->>MuiTableEditable: validate newValue

    alt Validation passes
        MuiTableEditable->>onCellChange: call with (rowId, colKey, newValue)
        onCellChange->>MuiTableEditable: update data
        MuiTableEditable->>TableCell: clear editing state, re-render cell
    else Validation fails
        MuiTableEditable->>TableCell: keep edit mode, show error
    end
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 I hopped in to tweak each row and cell,

Archived hues where old records dwell.
Click to edit, blur to save,
A tidy table—soft and brave.
🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: applying archived row styling to form items table, which aligns with the comprehensive styling updates across multiple components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/match-archive-row-color

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@priscila-moneo priscila-moneo marked this pull request as ready for review March 5, 2026 21:06
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/mui/editable-table/mui-table-editable.js (1)

303-334: ⚠️ Potential issue | 🟡 Minor

Missing width in edit and delete cell sx props.

In mui-table.js, the edit and delete cells pass { width: 40 } to getCellSx (lines 198 and 235), but here they don't include width. This may cause inconsistent cell sizing between the two table components.

🔧 Proposed fix
                  {onEdit && (
-                    <TableCell sx={getCellSx(row)}>
+                    <TableCell sx={getCellSx(row, { width: 40 })}>
                      <IconButton
...
                  {onDelete && (
-                    <TableCell sx={getCellSx(row)}>
+                    <TableCell sx={getCellSx(row, { width: 40 })}>
                      <IconButton
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/mui/editable-table/mui-table-editable.js` around lines 303 -
334, The edit and delete action TableCell usages in mui-table-editable.js omit
the width override passed elsewhere; update the TableCell that wraps the Edit
IconButton (onEdit) and the TableCell that wraps the delete control (onDelete)
to include the same width styling by passing a width value (e.g., { width: 40 })
into getCellSx — locate the TableCell elements around the onEdit and onDelete
handlers and call getCellSx(row, { width: 40 }) or otherwise merge { width: 40 }
into the sx prop so their cell sizing matches the mui-table counterparts.
🧹 Nitpick comments (2)
src/components/mui/table/mui-table.js (1)

31-87: Code duplication: ARCHIVED_CELL_SX and helpers exist in both table components.

The ARCHIVED_CELL_SX constant and getArchivedCellSx/getCellSx helpers are duplicated in src/components/mui/editable-table/mui-table-editable.js (lines 26-30 and 171-177). Consider extracting these into a shared utility module to ensure consistency and reduce maintenance burden if styling needs to change.

♻️ Example extraction

Create a shared utility file:

// src/components/mui/table/archived-cell-utils.js
export const ARCHIVED_CELL_SX = {
  backgroundColor: "background.light",
  color: "text.disabled"
};

export const getArchivedCellSx = (row, disableProp) =>
  disableProp && row[disableProp] ? ARCHIVED_CELL_SX : null;

export const getCellSx = (row, disableProp, baseSx = {}) => ({
  ...baseSx,
  ...(getArchivedCellSx(row, disableProp) || {})
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/mui/table/mui-table.js` around lines 31 - 87, ARCHIVED_CELL_SX
and the helpers getArchivedCellSx/getCellSx are duplicated; extract them into a
shared utility module (e.g., archived-cell-utils) and update both MuiTable
(symbols: ARCHIVED_CELL_SX, getArchivedCellSx, getCellSx) and the editable table
(mui-table-editable.js where the same symbols appear) to import and use the
shared functions; ensure the refactored helpers accept the disableProp (or
row/disableProp) so existing calls in handle cell rendering still work and
remove the duplicated definitions from both components.
src/components/mui/__tests__/mui-table-editable.test.js (1)

329-348: Consider documenting the cell index mapping.

The archivedCellIndexes = [0, 1, 2, 3, 5] relies on implicit knowledge of the column order (3 data columns + edit + archive + delete). A brief comment explaining which cells these indexes correspond to would improve maintainability.

📝 Suggested comment
     const cells = within(aliceRow).getAllByTestId("mui-table-cell");
 
-    const archivedCellIndexes = [0, 1, 2, 3, 5];
+    // Indexes: 0=name, 1=role, 2=age (content cols), 3=edit, 4=archive (excluded), 5=delete
+    const archivedCellIndexes = [0, 1, 2, 3, 5];
     archivedCellIndexes.forEach((index) => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/mui/__tests__/mui-table-editable.test.js` around lines 329 -
348, Add a brief inline comment above the archivedCellIndexes array in the test
"applies archived styles to content, edit and delete cells when disableProp
matches" to document the mapping between indexes and columns (e.g., which
indexes correspond to data columns, edit, archive, delete columns); update the
archivedCellIndexes declaration near where getCellSx(cells[index]) is used so
future readers can understand why [0,1,2,3,5] was chosen without inspecting the
table column order set up by setup(...) and screen/within calls.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/components/mui/editable-table/mui-table-editable.js`:
- Around line 303-334: The edit and delete action TableCell usages in
mui-table-editable.js omit the width override passed elsewhere; update the
TableCell that wraps the Edit IconButton (onEdit) and the TableCell that wraps
the delete control (onDelete) to include the same width styling by passing a
width value (e.g., { width: 40 }) into getCellSx — locate the TableCell elements
around the onEdit and onDelete handlers and call getCellSx(row, { width: 40 })
or otherwise merge { width: 40 } into the sx prop so their cell sizing matches
the mui-table counterparts.

---

Nitpick comments:
In `@src/components/mui/__tests__/mui-table-editable.test.js`:
- Around line 329-348: Add a brief inline comment above the archivedCellIndexes
array in the test "applies archived styles to content, edit and delete cells
when disableProp matches" to document the mapping between indexes and columns
(e.g., which indexes correspond to data columns, edit, archive, delete columns);
update the archivedCellIndexes declaration near where getCellSx(cells[index]) is
used so future readers can understand why [0,1,2,3,5] was chosen without
inspecting the table column order set up by setup(...) and screen/within calls.

In `@src/components/mui/table/mui-table.js`:
- Around line 31-87: ARCHIVED_CELL_SX and the helpers
getArchivedCellSx/getCellSx are duplicated; extract them into a shared utility
module (e.g., archived-cell-utils) and update both MuiTable (symbols:
ARCHIVED_CELL_SX, getArchivedCellSx, getCellSx) and the editable table
(mui-table-editable.js where the same symbols appear) to import and use the
shared functions; ensure the refactored helpers accept the disableProp (or
row/disableProp) so existing calls in handle cell rendering still work and
remove the duplicated definitions from both components.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6b56a695-6b5d-4504-8744-7d15a4765370

📥 Commits

Reviewing files that changed from the base of the PR and between 827fd4a and ef24cfa.

📒 Files selected for processing (5)
  • src/components/mui/__tests__/mui-table-editable.test.js
  • src/components/mui/editable-table/mui-table-editable.js
  • src/components/mui/table/mui-table.js
  • src/pages/sponsors/sponsor-form-item-list-page/index.js
  • src/pages/sponsors/sponsor-forms-tab/components/manage-items/sponsor-forms-manage-items.js

Copy link

@martinquiroga-exo martinquiroga-exo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@priscila-moneo please see comments. Thanks.

{data.map((row, idx) => (
// eslint-disable-next-line react/no-array-index-key
<TableRow key={`row-${idx}`} hover>
<TableRow key={`row-${idx}`}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<TableRow key={row.id}>

This table clearly has row.id, so the index should not be used.

Use a stable identifier. Using array index as a key breaks reconciliation if rows reorder, update, or paginate.


test("applies archived styles to content, edit and delete cells when disableProp matches", () => {
setup({
options: { sortCol: "name", sortDir: "-1", disableProp: "is_archived" },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sortDir should not be an string, it is expecting a number. This relies on implicit coercion.

options: { sortCol: "name", sortDir: -1, disableProp: "is_archived" },

@priscila-moneo priscila-moneo force-pushed the fix/match-archive-row-color branch from ef24cfa to 806909c Compare March 6, 2026 19:46
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/components/mui/table/mui-table.js (1)

31-34: Consider extracting shared styling utilities to a common module.

The ARCHIVED_CELL_SX constant and getArchivedCellSx/getCellSx helpers are duplicated verbatim in src/components/mui/editable-table/mui-table-editable.js (lines 26-29 and 171-177). Extracting these to a shared module (e.g., src/components/mui/table/table-utils.js) would reduce maintenance burden and ensure consistent styling across both table components.

Also applies to: 81-87

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/mui/table/mui-table.js` around lines 31 - 34, ARCHIVED_CELL_SX
and the helpers getArchivedCellSx/getCellSx are duplicated across mui-table.js
and mui-table-editable.js; extract them into a shared module (e.g.,
table-utils.js) and import them from both components: create a small module that
exports ARCHIVED_CELL_SX, getArchivedCellSx, and getCellSx, update mui-table.js
to import those symbols instead of defining them, and update
mui-table-editable.js to remove the duplicated definitions and import the same
symbols so both components reuse the single implementation.
src/components/mui/__tests__/mui-table-editable.test.js (1)

342-347: Consider using semantic selectors instead of hardcoded cell indexes.

The hardcoded indexes [0, 1, 2, 3, 5] assume a specific cell order (3 data columns + edit + archive + delete). If columns are reordered or optional action columns change, this test could silently pass incorrectly or fail unexpectedly. Consider querying cells by role or data attribute to make the test more resilient.

💡 Example approach
// Instead of hardcoded indexes, identify cells by context
const nameCellSx = getCellSx(screen.getByText("Alice").closest("td"));
const editCellSx = getCellSx(within(aliceRow).getByLabelText("general.edit").closest("td"));
const deleteCellSx = getCellSx(within(aliceRow).getByLabelText("general.delete").closest("td"));

[nameCellSx, editCellSx, deleteCellSx].forEach((sx) => {
  expect(sx.backgroundColor).toBe("background.light");
  expect(sx.color).toBe("text.disabled");
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/mui/__tests__/mui-table-editable.test.js` around lines 342 -
347, The test currently relies on hardcoded indexes in archivedCellIndexes and
getCellSx(cells[index]), which is brittle; update the test to locate cells
semantically instead (e.g., use screen.getByText/closest('td') for data cells,
within(row).getByLabelText('general.edit') or 'general.delete' for action cells)
and pass those td elements into getCellSx instead of indexing into cells; keep
the same assertions on sx.backgroundColor and sx.color but build the array of
cell elements by querying content/aria-labels (referencing getCellSx,
archivedCellIndexes, and cells to find and replace the indexing logic).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/components/mui/__tests__/mui-table-editable.test.js`:
- Around line 342-347: The test currently relies on hardcoded indexes in
archivedCellIndexes and getCellSx(cells[index]), which is brittle; update the
test to locate cells semantically instead (e.g., use
screen.getByText/closest('td') for data cells,
within(row).getByLabelText('general.edit') or 'general.delete' for action cells)
and pass those td elements into getCellSx instead of indexing into cells; keep
the same assertions on sx.backgroundColor and sx.color but build the array of
cell elements by querying content/aria-labels (referencing getCellSx,
archivedCellIndexes, and cells to find and replace the indexing logic).

In `@src/components/mui/table/mui-table.js`:
- Around line 31-34: ARCHIVED_CELL_SX and the helpers
getArchivedCellSx/getCellSx are duplicated across mui-table.js and
mui-table-editable.js; extract them into a shared module (e.g., table-utils.js)
and import them from both components: create a small module that exports
ARCHIVED_CELL_SX, getArchivedCellSx, and getCellSx, update mui-table.js to
import those symbols instead of defining them, and update mui-table-editable.js
to remove the duplicated definitions and import the same symbols so both
components reuse the single implementation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a3eb2e0d-1b15-48a1-a3b7-c6d2eadd47b1

📥 Commits

Reviewing files that changed from the base of the PR and between ef24cfa and 806909c.

📒 Files selected for processing (5)
  • src/components/mui/__tests__/mui-table-editable.test.js
  • src/components/mui/editable-table/mui-table-editable.js
  • src/components/mui/table/mui-table.js
  • src/pages/sponsors/sponsor-form-item-list-page/index.js
  • src/pages/sponsors/sponsor-forms-tab/components/manage-items/sponsor-forms-manage-items.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/sponsors/sponsor-form-item-list-page/index.js

Copy link

@martinquiroga-exo martinquiroga-exo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants