Skip to content

fix: add new v2 versions of draggable components #285

Open
tomrndom wants to merge 14 commits into
mainfrom
fix/react-dnd-v2-components
Open

fix: add new v2 versions of draggable components #285
tomrndom wants to merge 14 commits into
mainfrom
fix/react-dnd-v2-components

Conversation

@tomrndom

@tomrndom tomrndom commented Jul 8, 2026

Copy link
Copy Markdown
Contributor
  • replacing react-beautiful-dnd for @dnd-kit/sortable on new versions

ref: https://app.clickup.com/t/9014802374/86b94xa4t

Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com

Summary by CodeRabbit

  • New Features
    • Added MuiTableSortableV2 with sortable headers, drag-and-drop row reordering, pagination, and edit/delete actions (with confirmation).
    • Introduced v2 additional-input editor components: AdditionalInputV2, AdditionalInputListV2, and MetaFieldValuesV2.
  • Bug Fixes
    • “Add value” is disabled when any meta-field value has an empty/blank name or value.
    • Only one meta-field value can be marked as default.
    • Delete flow preserves the UI when deletion fails (and uses the warning icon in the confirmation dialog).
  • Tests
    • Expanded Jest coverage for v2 meta-field values and sortable-table behavior, confirmation flows, and v2 entry-point wiring; tightened v1 tests.
  • Style
    • Added a dotted left-border utility for the sortable table UI.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds shared Formik-backed V1/V2 metafield editors and a new draggable, sortable MUI table. The change includes confirmation flows, validation, pagination, build wiring, and Jest coverage for editor and table interactions.

Changes

AdditionalInput and MetaFieldValues V2

Layer / File(s) Summary
Shared metafield editor implementation
src/components/mui/formik-inputs/additional-input/*-core.js
Adds shared Formik row/list behavior, type-dependent fields, completeness checks, add/remove flows, and confirmation-based deletion.
MetaFieldValuesV2 behavior and wrappers
src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js, src/components/mui/formik-inputs/additional-input/*-v2.js, src/components/mui/formik-inputs/additional-input/additional-input.js
Adds sorted value rendering, drag reordering, value creation, exclusive defaults, validation, deletion, and V1/V2 component wiring.
Entry-point and behavior tests
src/components/mui/__tests__/additional-input*, src/components/mui/__tests__/meta-field-values*.test.js, src/components/index.js
Tests shared editor behavior, V1/V2 wiring, value management, and confirmation-dialog configuration.

MuiTableSortableV2 sortable table

Layer / File(s) Summary
SortableRow drag wrapper
src/components/mui/sortable-table-v2/sortable-row.js, src/components/mui/sortable-table-v2/styles.module.less
Adds dnd-kit row behavior, drag-handle properties, dragging styles, and a dotted border style.
MuiTableSortableV2 core implementation
src/components/mui/sortable-table-v2/mui-table-sortable-v2.js
Adds sortable headers, draggable rows, edit/delete actions, pagination, empty-state rendering, and row-reordering callbacks.
Table tests and build entry
src/components/mui/__tests__/mui-table-sortable-v2.test.js, webpack.common.js
Tests table rendering, deletion, pagination, editing, and drag reordering, and adds the sortable-table-v2 webpack entry.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant AdditionalInput
  participant MetaFieldValuesV2
  participant Formik
  User->>AdditionalInput: render V1 or V2 entry point
  AdditionalInput->>MetaFieldValuesV2: inject V2 values component
  User->>MetaFieldValuesV2: add, reorder, edit, or remove value
  MetaFieldValuesV2->>Formik: setFieldValue(updated values)
Loading
sequenceDiagram
  participant User
  participant SortableRow
  participant MuiTableSortableV2
  participant onReorder
  User->>SortableRow: drag row
  SortableRow->>MuiTableSortableV2: report drag end
  MuiTableSortableV2->>onReorder: send reordered rows
Loading

Possibly related PRs

Suggested reviewers: smarcet

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding v2 draggable component variants.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/react-dnd-v2-components

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.

tomrndom added 2 commits July 8, 2026 15:30
…tiful-dnd for @dnd-kit/sortable

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@tomrndom
tomrndom force-pushed the fix/react-dnd-v2-components branch from 2cb07b0 to 5c3ebac Compare July 8, 2026 18:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 8

♻️ Duplicate comments (1)
src/components/mui/formik-inputs/additional-input/additional-input-list-v2.js (1)

50-59: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Same type/iconType mismatch as MetaFieldValuesV2

showConfirmDialog destructures iconType, not type. The warning icon won't be displayed.

🔧 Proposed fix
     const isConfirmed = await showConfirmDialog({
       title: T.translate("general.are_you_sure"),
       text: `${T.translate("additional_inputs.delete_warning")} ${
         item.name
       }`,
-      type: "warning",
+      iconType: "warning",
       confirmButtonColor: "`#DD6B55`",
       confirmButtonText: T.translate("general.yes_delete")
     });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/components/mui/formik-inputs/additional-input/additional-input-list-v2.js`
around lines 50 - 59, The confirm dialog call in handleRemove uses the wrong
option name, so the warning icon is not passed through to showConfirmDialog.
Update the dialog config in additional-input-list-v2.js to use iconType instead
of type, matching the existing destructuring used by showConfirmDialog and the
similar MetaFieldValuesV2 flow.
🧹 Nitpick comments (3)
src/components/mui/formik-inputs/additional-input/additional-input-list-v2.js (1)

72-75: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

No user feedback on API deletion failure

The .catch() handler logs the error but provides no UI feedback. The user sees no indication that the deletion failed and the item remains in the list with no explanation.

💡 Suggested improvement
     onDelete(entityId, item.id)
       .then(() => removeFromUI())
-      .catch((err) => console.error("Error deleting field from API", err));
+      .catch((err) => {
+        console.error("Error deleting field from API", err);
+        // Add user-facing error feedback, e.g.:
+        // showConfirmDialog({ title: T.translate("general.error"), text: T.translate("additional_inputs.delete_error"), iconType: "error" });
+      });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/components/mui/formik-inputs/additional-input/additional-input-list-v2.js`
around lines 72 - 75, The deletion flow in additional-input-list-v2.js only logs
API failures in the onDelete promise chain and gives no user-facing feedback.
Update the handler around the item.id / onDelete path so the .catch() also
surfaces the failure in the UI, using the existing removeFromUI and error
handling logic as the reference point. Ensure the user is informed that the
delete failed and the item remains in place with an explanatory message or
equivalent UI state.
src/components/mui/__tests__/mui-table-sortable-v2.test.js (2)

145-165: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Tests rely on fragile button index selection.

screen.getAllByRole("button")[1] depends on the exact render order of buttons. If a column is added, made sortable, or an action column is reordered, these tests will silently click the wrong button. Consider adding aria-label or data-testid attributes to the edit/delete/reorder buttons in the component and selecting by those.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/mui/__tests__/mui-table-sortable-v2.test.js` around lines 145
- 165, The tests in mui-table-sortable-v2 are using fragile button index
selection through getAllByRole("button")[1], which can break when the render
order changes. Update the component’s edit/delete/reorder buttons to expose
stable selectors such as aria-label or data-testid, then change the affected
tests to target those specific controls instead of relying on array positions.
Use the MuiTableSortableV2 action button rendering and the existing onEdit,
onDelete, and showConfirmDialog flows to locate the right elements.

119-182: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Missing test coverage for core features: drag-end reordering, sort, and per-page change.

The dnd-kit mocks render children directly, so handleDragEnd (the core reordering logic) is never exercised. Additionally, there are no tests for:

  • onSort callback when clicking a sortable column header
  • onPerPageChange when changing rows per page (the mock has a "change-rows" button but no test uses it)
  • Delete cancellation (showConfirmDialog returns falseonDelete should not be called)
  • idKey prop with a non-"id" key
🧪 Suggested additional tests
test("calls onSort when sortable column header is clicked", async () => {
  const onSort = jest.fn();
  setup({ onSort });
  const sortButton = screen.getByText("Name").closest("button");
  await userEvent.click(sortButton);
  expect(onSort).toHaveBeenCalledWith("name", -1);
});

test("does not call onDelete when delete is cancelled", async () => {
  const onDelete = jest.fn();
  showConfirmDialog.mockResolvedValueOnce(false);
  setup({ onDelete });
  const buttons = screen.getAllByRole("button");
  await userEvent.click(buttons[1]);
  await new Promise((r) => setTimeout(r, 0));
  expect(showConfirmDialog).toHaveBeenCalled();
  expect(onDelete).not.toHaveBeenCalled();
});

test("calls onPerPageChange when rows per page is changed", async () => {
  const onPerPageChange = jest.fn();
  setup({ onPerPageChange });
  await userEvent.click(screen.getByLabelText("change-rows"));
  expect(onPerPageChange).toHaveBeenCalledWith(10);
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/mui/__tests__/mui-table-sortable-v2.test.js` around lines 119
- 182, Add missing coverage in MuiTableSortableV2 tests for the core
interactions that aren’t exercised by the current dnd-kit mock setup: verify
handleDragEnd/reordering via the component’s drag behavior, assert onSort fires
when clicking the sortable header in MuiTableSortableV2, add a test for
onPerPageChange using the change-rows control, cover delete cancellation by
mocking showConfirmDialog to return false and ensuring onDelete is not called,
and add a case for idKey with a non-id field so the row action handlers still
target the correct item.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/index.js`:
- Around line 142-144: The export stub name is inconsistent with the actual
component/module name, which can cause import confusion when enabled. Update the
stub in the components index to use the same identifier as the module and test,
`MuiTableSortableV2`, and keep the related exports for `MuiAdditionalInputV2`
and `MuiAdditionalInputListV2` aligned with their existing names.

In `@src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js`:
- Around line 41-45: The handlers in meta-field-values-v2.js are mutating Formik
state in place even though they make shallow copies first. Update onReorder,
handleDefaultChange, and removeValueFromFields to create fully immutable updates
by cloning the affected field object at fieldIndex and any nested value objects
before changing values, then pass the new structure to setFieldValue. Use the
existing symbols onReorder, handleDefaultChange, removeValueFromFields, and
metaFields to locate and rewrite the state updates without mutating shared
objects.
- Around line 47-54: `handleAddValue` in `meta-field-values-v2.js` is appending
new value objects without an `order`, which leaves them unsorted until a drag
occurs. Update the new object added in `handleAddValue` to include a computed
`order` based on the current field’s existing values (for example, the next
index in that array), and keep the structure consistent with the value objects
used by `DragNDropList` so the initial sort can work deterministically.
- Around line 74-100: The delete flow in handleRemoveValue needs two fixes: pass
the confirmation icon using showConfirmDialog’s expected iconType option instead
of type so the warning icon appears, and add a catch path to the
onMetaFieldTypeValueDeleted(entityId, field.id, metaFieldValue.id) promise
before calling removeValueFromFields. If the API call fails, do not remove the
value and handle the rejection gracefully to avoid an unhandled promise
rejection.

In `@src/components/mui/sortable-table/mui-table-sortable-v2.js`:
- Around line 136-153: handleDelete is hardcoded to delete with item.id, which
breaks consumers that pass a different identifier via the idKey prop. Update the
delete flow in mui-table-sortable-v2.js so handleDelete uses item[idKey] when
calling onDelete, keeping it consistent with the existing idKey-based lookup
used elsewhere in the sortable table component.
- Around line 285-291: The empty-state row in mui-table-sortable-v2 does not
span the extra action columns added by onEdit, onDelete, or onReorder, so the
no-items message only covers the data columns. Update the TableCell colSpan in
the empty-state branch to include the base columns plus any enabled action
columns, using the same flags and rendering logic used by the table header in
mui-table-sortable-v2 so the width stays aligned.
- Around line 106-134: `handleDragEnd` in `mui-table-sortable-v2` is mutating
the original `data` items when updating `updateOrderKey`, so switch to creating
copied row objects before reordering and updating order values, rather than
writing into the existing references returned by `arrayMove`. Also make the
moved-item lookup consistent by using `idKey` everywhere in `handleDragEnd`
instead of hardcoding `movedItem.id`, so `newOrder` resolves correctly when the
row id field is not named `id`.

In `@src/components/mui/sortable-table/sortable-row.js`:
- Around line 34-49: The dragging styles in SortableRow are overriding the
dnd-kit transform by setting a separate scale value inside the isDragging
spread. Update the existing transform handling in sortable-row.js so the row
keeps the CSS.Transform.toString(transform) translation and also applies the
scale effect in the same transform string when isDragging is true, instead of
replacing it with only scale(1.01).

---

Duplicate comments:
In
`@src/components/mui/formik-inputs/additional-input/additional-input-list-v2.js`:
- Around line 50-59: The confirm dialog call in handleRemove uses the wrong
option name, so the warning icon is not passed through to showConfirmDialog.
Update the dialog config in additional-input-list-v2.js to use iconType instead
of type, matching the existing destructuring used by showConfirmDialog and the
similar MetaFieldValuesV2 flow.

---

Nitpick comments:
In `@src/components/mui/__tests__/mui-table-sortable-v2.test.js`:
- Around line 145-165: The tests in mui-table-sortable-v2 are using fragile
button index selection through getAllByRole("button")[1], which can break when
the render order changes. Update the component’s edit/delete/reorder buttons to
expose stable selectors such as aria-label or data-testid, then change the
affected tests to target those specific controls instead of relying on array
positions. Use the MuiTableSortableV2 action button rendering and the existing
onEdit, onDelete, and showConfirmDialog flows to locate the right elements.
- Around line 119-182: Add missing coverage in MuiTableSortableV2 tests for the
core interactions that aren’t exercised by the current dnd-kit mock setup:
verify handleDragEnd/reordering via the component’s drag behavior, assert onSort
fires when clicking the sortable header in MuiTableSortableV2, add a test for
onPerPageChange using the change-rows control, cover delete cancellation by
mocking showConfirmDialog to return false and ensuring onDelete is not called,
and add a case for idKey with a non-id field so the row action handlers still
target the correct item.

In
`@src/components/mui/formik-inputs/additional-input/additional-input-list-v2.js`:
- Around line 72-75: The deletion flow in additional-input-list-v2.js only logs
API failures in the onDelete promise chain and gives no user-facing feedback.
Update the handler around the item.id / onDelete path so the .catch() also
surfaces the failure in the UI, using the existing removeFromUI and error
handling logic as the reference point. Ensure the user is informed that the
delete failed and the item remains in place with an explanatory message or
equivalent UI state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 13c13ff4-c52f-4976-a261-ae17ee5cdacc

📥 Commits

Reviewing files that changed from the base of the PR and between 72d7f58 and 6637f91.

📒 Files selected for processing (10)
  • src/components/index.js
  • src/components/mui/__tests__/additional-input-v2.test.js
  • src/components/mui/__tests__/meta-field-values-v2.test.js
  • src/components/mui/__tests__/mui-table-sortable-v2.test.js
  • src/components/mui/formik-inputs/additional-input/additional-input-list-v2.js
  • src/components/mui/formik-inputs/additional-input/additional-input-v2.js
  • src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js
  • src/components/mui/sortable-table/mui-table-sortable-v2.js
  • src/components/mui/sortable-table/sortable-row.js
  • webpack.common.js

Comment thread src/components/index.js Outdated
Comment thread src/components/mui/sortable-table-v2/mui-table-sortable-v2.js Outdated
Comment thread src/components/mui/sortable-table-v2/mui-table-sortable-v2.js
Comment thread src/components/mui/sortable-table-v2/mui-table-sortable-v2.js
Comment thread src/components/mui/sortable-table-v2/sortable-row.js

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces “V2” variants of draggable MUI components that use @dnd-kit/* (instead of react-beautiful-dnd), and wires them into the build as new entrypoints while adding Jest coverage for the new variants.

Changes:

  • Add new webpack entrypoints for sortable-table-v2 and additional-input(-list)-v2.
  • Implement MuiTableSortableV2 + SortableRow using @dnd-kit/core / @dnd-kit/sortable.
  • Implement V2 additional-input meta-field value management using the shared DragNDropList, plus new tests for the V2 components.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
webpack.common.js Adds new build entrypoints for the V2 components.
src/components/mui/sortable-table/sortable-row.js New dnd-kit powered sortable row wrapper for MUI tables.
src/components/mui/sortable-table/mui-table-sortable-v2.js New sortable table implementation using dnd-kit + MUI pagination/actions.
src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js New meta-field values editor with drag reordering via DragNDropList.
src/components/mui/formik-inputs/additional-input/additional-input-v2.js New additional-input V2 component integrating meta-field values management.
src/components/mui/formik-inputs/additional-input/additional-input-list-v2.js New list wrapper for additional-input V2 items and delete/add flows.
src/components/mui/tests/mui-table-sortable-v2.test.js Tests for V2 sortable table rendering + actions + pagination.
src/components/mui/tests/meta-field-values-v2.test.js Tests for meta-field values V2 behavior (add/remove/default).
src/components/mui/tests/additional-input-v2.test.js Integration-style tests between AdditionalInputV2 and MetaFieldValuesV2.
src/components/index.js Adds commented-out export hints for the new V2 components.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/mui/sortable-table/mui-table-sortable-v2.js Outdated
Comment thread src/components/mui/sortable-table-v2/mui-table-sortable-v2.js
Comment thread src/components/mui/sortable-table/mui-table-sortable-v2.js Outdated
Comment thread src/components/mui/sortable-table/mui-table-sortable-v2.js
Comment thread src/components/mui/sortable-table-v2/sortable-row.js
Comment thread src/components/mui/sortable-table/mui-table-sortable-v2.js
Comment thread src/components/mui/sortable-table-v2/mui-table-sortable-v2.js
tomrndom added 2 commits July 8, 2026 15:48
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@smarcet
smarcet requested review from santipalenque and smarcet July 13, 2026 13:35
Comment thread src/components/mui/formik-inputs/additional-input/additional-input-v2.js Outdated
Comment thread src/components/mui/sortable-table-v2/mui-table-sortable-v2.js
tomrndom added 2 commits July 14, 2026 03:02
…component on additional input

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js (1)

84-111: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Handle the API failure path and pass the confirm icon prop.

This is a friendly reminder that the issues identified in a previous review for the deletion flow have not been addressed:

  • Pass the confirmation icon using showConfirmDialog’s expected iconType option instead of type so the warning icon appears.
  • Add a .catch() block to the onMetaFieldTypeValueDeleted(entityId, field.id, metaFieldValue.id) promise before calling removeValueFromFields. If the API call fails, the application should handle the rejection gracefully to avoid an unhandled promise rejection.
🔧 Proposed fix for the delete flow
   const handleRemoveValue = async (metaFieldValue, valueIndex) => {
     const isConfirmed = await showConfirmDialog({
       title: T.translate("general.are_you_sure"),
       text: T.translate("meta_fields.delete_value_warning"),
-      type: "warning",
+      iconType: "warning",
       confirmButtonColor: "`#DD6B55`",
       confirmButtonText: T.translate("general.yes_delete")
     });

     if (!isConfirmed) return;

     const removeValueFromFields = () => {
       const newFields = metaFields.map((f, i) =>
         i === fieldIndex
           ? { ...f, values: f.values.filter((_, index) => index !== valueIndex) }
           : f
       );
       setFieldValue(baseName, newFields);
     };

     if (field.id && metaFieldValue.id && onMetaFieldTypeValueDeleted) {
-      onMetaFieldTypeValueDeleted(entityId, field.id, metaFieldValue.id).then(
-        () => removeValueFromFields()
-      );
+      onMetaFieldTypeValueDeleted(entityId, field.id, metaFieldValue.id)
+        .then(() => removeValueFromFields())
+        .catch((err) => console.error("Failed to delete value", err));
     } else {
       removeValueFromFields();
     }
   };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js`
around lines 84 - 111, Update handleRemoveValue to pass the warning icon through
showConfirmDialog’s iconType option instead of type, and add rejection handling
to the onMetaFieldTypeValueDeleted promise chain before removeValueFromFields.
Ensure API failures are handled gracefully without removing the value or
producing an unhandled promise rejection.
🧹 Nitpick comments (1)
src/components/mui/sortable-table-v2/mui-table-sortable-v2.js (1)

174-192: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding sortDirection on the header TableCell for proper ARIA sort semantics.

MUI's recommended pattern pairs TableSortLabel with sortDirection on the enclosing TableCell (sortDirection={sortCol === col.columnKey ? (sortDir === -1 ? "desc" : "asc") : false}) so screen readers announce the active sort column/direction via aria-sort. Currently only the visually-hidden text conveys this.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/mui/sortable-table-v2/mui-table-sortable-v2.js` around lines
174 - 192, Update the enclosing header TableCell in the sortable column
rendering to provide sortDirection based on sortCol and sortDir: use "desc" or
"asc" for the active column and false otherwise, while preserving the existing
TableSortLabel behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js`:
- Around line 84-111: Update handleRemoveValue to pass the warning icon through
showConfirmDialog’s iconType option instead of type, and add rejection handling
to the onMetaFieldTypeValueDeleted promise chain before removeValueFromFields.
Ensure API failures are handled gracefully without removing the value or
producing an unhandled promise rejection.

---

Nitpick comments:
In `@src/components/mui/sortable-table-v2/mui-table-sortable-v2.js`:
- Around line 174-192: Update the enclosing header TableCell in the sortable
column rendering to provide sortDirection based on sortCol and sortDir: use
"desc" or "asc" for the active column and false otherwise, while preserving the
existing TableSortLabel behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e8dd9d4f-b9cc-41df-85c0-c19bb79f451e

📥 Commits

Reviewing files that changed from the base of the PR and between 6637f91 and 368013a.

📒 Files selected for processing (11)
  • src/components/index.js
  • src/components/mui/__tests__/additional-input.test.js
  • src/components/mui/__tests__/meta-field-values-v2.test.js
  • src/components/mui/__tests__/mui-table-sortable-v2.test.js
  • src/components/mui/formik-inputs/additional-input/additional-input-list.js
  • src/components/mui/formik-inputs/additional-input/additional-input.js
  • src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js
  • src/components/mui/sortable-table-v2/mui-table-sortable-v2.js
  • src/components/mui/sortable-table-v2/sortable-row.js
  • src/components/mui/sortable-table-v2/styles.module.less
  • webpack.common.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/components/index.js
  • webpack.common.js
  • src/components/mui/tests/meta-field-values-v2.test.js

Comment thread src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js Outdated
Comment thread src/components/mui/sortable-table-v2/mui-table-sortable-v2.js Outdated
Comment thread src/components/index.js Outdated
Comment thread src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js Outdated

@smarcet smarcet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@tomrndom please re review

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/__tests__/meta-field-values-v2.test.js (2)

397-404: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prefer semantic queries over test IDs and DOM traversal.

Using getByRole with the accessible name is more resilient and idiomatic in React Testing Library than querying an SVG icon by test ID and calling .closest("button"). The component already provides aria-label="remove value" on the remove buttons.

♻️ Proposed refactor
-    const closeButton = screen.getAllByTestId("CloseIcon")[0].closest("button");
+    const closeButton = screen.getAllByRole("button", { name: /remove value/i })[0];
     await userEvent.click(closeButton);
 
     await waitFor(() => expect(mockOnDelete).toHaveBeenCalled());
 
     // today: silently stays at 2 items, no error surfaced
-    expect(screen.getAllByTestId("CloseIcon")).toHaveLength(2);
+    expect(screen.getAllByRole("button", { name: /remove value/i })).toHaveLength(2);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/mui/__tests__/meta-field-values-v2.test.js` around lines 397 -
404, Update the test’s close-button lookup to use a semantic role query for the
button with accessible name “remove value,” replacing the CloseIcon test ID
lookup and closest("button") traversal. Keep the existing click, mockOnDelete
assertion, and remaining-item count expectations unchanged.

186-188: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Make the order assertion explicit and remove stale debugging comments.

Asserting the exact expected array (e.g., [1, 3, 4]) is more robust than checking for uniqueness, and the fails today: comment appears to be a leftover from debugging prior to fixing the component.

♻️ Proposed refactor
       await waitFor(() => {
         const orders = latestValues.meta_fields[0].values.map((v) => v.order);
-        expect(new Set(orders).size).toBe(orders.length); // fails today: [1, 3, 3]
+        expect(orders).toEqual([1, 3, 4]);
       });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/mui/__tests__/meta-field-values-v2.test.js` around lines 186 -
188, Update the order assertion in the meta-field values test to compare orders
against the exact expected array [1, 3, 4] rather than only checking Set
uniqueness, and remove the stale “fails today” debugging comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/components/mui/__tests__/meta-field-values-v2.test.js`:
- Around line 397-404: Update the test’s close-button lookup to use a semantic
role query for the button with accessible name “remove value,” replacing the
CloseIcon test ID lookup and closest("button") traversal. Keep the existing
click, mockOnDelete assertion, and remaining-item count expectations unchanged.
- Around line 186-188: Update the order assertion in the meta-field values test
to compare orders against the exact expected array [1, 3, 4] rather than only
checking Set uniqueness, and remove the stale “fails today” debugging comment.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2dffd1b3-9b26-4c80-8047-0692b1e06743

📥 Commits

Reviewing files that changed from the base of the PR and between 368013a and d27f993.

📒 Files selected for processing (6)
  • src/components/index.js
  • src/components/mui/__tests__/meta-field-values-v2.test.js
  • src/components/mui/__tests__/mui-table-sortable-v2.test.js
  • src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js
  • src/components/mui/sortable-table-v2/mui-table-sortable-v2.js
  • webpack.common.js
💤 Files with no reviewable changes (1)
  • webpack.common.js
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/components/index.js
  • src/components/mui/tests/mui-table-sortable-v2.test.js
  • src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js
  • src/components/mui/sortable-table-v2/mui-table-sortable-v2.js

tomrndom added 2 commits July 20, 2026 18:04
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@smarcet
smarcet requested review from santipalenque and smarcet July 21, 2026 13:50
Comment thread src/components/mui/formik-inputs/additional-input/additional-input.js Outdated
Comment thread src/components/mui/sortable-table-v2/mui-table-sortable-v2.js Outdated

@smarcet smarcet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@tomrndom please review

@santipalenque santipalenque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (3)
src/components/mui/__tests__/additional-input-list-core.test.js (1)

209-239: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test doesn't assert the UI actually updates after successful delete.

This only checks mockOnDelete was called with the right args, not that removeFromUI ran afterward (e.g. field-count decreasing). Other tests in this suite do assert the post-removal count; adding the same here would close the gap for this specific path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/mui/__tests__/additional-input-list-core.test.js` around lines
209 - 239, The test “calls API and removes from UI when item has id” should also
verify the UI updates after a successful deletion. After awaiting the delete
action, assert that the field-count element decreases from 1 to 0, while
retaining the existing mockOnDelete argument assertion.
src/components/mui/formik-inputs/additional-input/additional-input-list-core.js (2)

20-27: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

_key generation is duplicated and collision-prone.

\draft_${Date.now()}`is repeated at three call sites (init effect, add, and remove-to-empty).Date.now()has millisecond resolution, so two drafts created in the same tick (e.g. rapid clicks, or the initial effect firing alongside a synchronous add) can produce identical_keyvalues, which are used as the ReactkeyforAdditionalInputComponent` (Line 113) and can cause incorrect reconciliation.

♻️ Suggested helper
+let draftCounter = 0;
+const createDraftMetaField = () => ({
+  ...DEFAULT_META_FIELD,
+  _key: `draft_${Date.now()}_${draftCounter++}`
+});

Then replace each { ...DEFAULT_META_FIELD, _key: \draft_${Date.now()}` }withcreateDraftMetaField()`.

Also applies to: 40-46, 48-53, 68-73

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/components/mui/formik-inputs/additional-input/additional-input-list-core.js`
around lines 20 - 27, Introduce a createDraftMetaField helper near
DEFAULT_META_FIELD that returns a fresh meta field with a collision-resistant
unique _key, then replace the duplicated draft_${Date.now()} constructions in
the initialization effect, add flow, and remove-to-empty flow with this helper.

109-125: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

areMetafieldsIncomplete() is recomputed for every row.

The result doesn't depend on itemIdx, yet it's invoked once per item inside .map (Line 121), making this O(n) redundant calls per render for an n-item list. Hoist it once above the map.

♻️ Suggested fix
+  const isAddDisabled = areMetafieldsIncomplete();
+
   return (
     <>
       {metaFields.map((item, itemIdx) => (
         <AdditionalInputComponent
           key={item.id || item._key}
           item={item}
           itemIdx={itemIdx}
           baseName={name}
           onAdd={handleAddItem}
           onDelete={handleRemove}
           onDeleteValue={onDeleteValue}
           entityId={entityId}
-          isAddDisabled={areMetafieldsIncomplete()}
+          isAddDisabled={isAddDisabled}
         />
       ))}
     </>
   );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/components/mui/formik-inputs/additional-input/additional-input-list-core.js`
around lines 109 - 125, Compute areMetafieldsIncomplete() once before the
metaFields.map call in the component’s render flow, store the result in a local
value, and pass that value to each AdditionalInputComponent via isAddDisabled
instead of invoking the function per row.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/mui/__tests__/additional-input-list-core.test.js`:
- Around line 193-207: Update the confirmation-dialog assertion in the “shows
confirmation dialog when delete is clicked” test to expect the corrected
iconType property instead of type, matching the caller behavior in
additional-input-list-core.js. Keep the existing warning value and other dialog
assertions unchanged.

In
`@src/components/mui/formik-inputs/additional-input/additional-input-list-core.js`:
- Around line 77-84: Update the deletion handler around onDelete and
removeFromUI so rejected API deletions surface a user-visible error through the
component’s existing toast or alert mechanism, while preserving the current
behavior of removing the item only after successful deletion. Replace or
supplement the console.error path in the catch handler without changing the
local-only deletion branch.
- Around line 55-64: Replace the unsupported type option in handleRemove’s
showConfirmDialog call with the iconType option set to "warning", ensuring the
warning icon is forwarded to GlobalConfirmDialog and ConfirmDialog.

---

Nitpick comments:
In `@src/components/mui/__tests__/additional-input-list-core.test.js`:
- Around line 209-239: The test “calls API and removes from UI when item has id”
should also verify the UI updates after a successful deletion. After awaiting
the delete action, assert that the field-count element decreases from 1 to 0,
while retaining the existing mockOnDelete argument assertion.

In
`@src/components/mui/formik-inputs/additional-input/additional-input-list-core.js`:
- Around line 20-27: Introduce a createDraftMetaField helper near
DEFAULT_META_FIELD that returns a fresh meta field with a collision-resistant
unique _key, then replace the duplicated draft_${Date.now()} constructions in
the initialization effect, add flow, and remove-to-empty flow with this helper.
- Around line 109-125: Compute areMetafieldsIncomplete() once before the
metaFields.map call in the component’s render flow, store the result in a local
value, and pass that value to each AdditionalInputComponent via isAddDisabled
instead of invoking the function per row.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 736ab949-eeba-4579-b2bb-90ed2111e49a

📥 Commits

Reviewing files that changed from the base of the PR and between d27f993 and d8785dd.

📒 Files selected for processing (17)
  • src/components/index.js
  • src/components/mui/__tests__/additional-input-core.test.js
  • src/components/mui/__tests__/additional-input-list-core.test.js
  • src/components/mui/__tests__/additional-input-list-v2.test.js
  • src/components/mui/__tests__/additional-input-list.test.js
  • src/components/mui/__tests__/additional-input-v2.test.js
  • src/components/mui/__tests__/additional-input.test.js
  • src/components/mui/__tests__/meta-field-values-v2.test.js
  • src/components/mui/formik-inputs/additional-input/additional-input-core.js
  • src/components/mui/formik-inputs/additional-input/additional-input-list-core.js
  • src/components/mui/formik-inputs/additional-input/additional-input-list-v2.js
  • src/components/mui/formik-inputs/additional-input/additional-input-list.js
  • src/components/mui/formik-inputs/additional-input/additional-input-v2.js
  • src/components/mui/formik-inputs/additional-input/additional-input.js
  • src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js
  • src/components/mui/sortable-table-v2/mui-table-sortable-v2.js
  • webpack.common.js
🚧 Files skipped from review as they are similar to previous changes (4)
  • webpack.common.js
  • src/components/mui/sortable-table-v2/mui-table-sortable-v2.js
  • src/components/mui/formik-inputs/additional-input/meta-field-values-v2.js
  • src/components/mui/tests/meta-field-values-v2.test.js

Comment thread src/components/mui/__tests__/additional-input-list-core.test.js
Comment on lines +77 to +84
if (item.id && onDelete) {
onDelete(entityId, item.id)
.then(() => removeFromUI())
.catch((err) => console.error("Error deleting field from API", err));
} else {
removeFromUI();
}
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

API delete failure is swallowed with only console.error.

If onDelete rejects, removeFromUI never runs, but nothing informs the user their deletion failed — from their perspective the click did nothing. Consider surfacing the error (toast/alert) so a failed deletion isn't silently ignored.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/components/mui/formik-inputs/additional-input/additional-input-list-core.js`
around lines 77 - 84, Update the deletion handler around onDelete and
removeFromUI so rejected API deletions surface a user-visible error through the
component’s existing toast or alert mechanism, while preserving the current
behavior of removing the item only after successful deletion. Replace or
supplement the console.error path in the catch handler without changing the
local-only deletion branch.

tomrndom added 2 commits July 21, 2026 17:09
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/mui/__tests__/meta-field-values.test.js`:
- Line 238: Update the relevant showConfirmDialog assertion in the
meta-field-values test to use the producer’s iconType key instead of typeIcon,
preserving the expected "warning" value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 85193202-002e-4967-b548-19f0ddb0bf21

📥 Commits

Reviewing files that changed from the base of the PR and between d8785dd and 877b8a8.

📒 Files selected for processing (4)
  • src/components/mui/__tests__/additional-input-list-core.test.js
  • src/components/mui/__tests__/meta-field-values.test.js
  • src/components/mui/formik-inputs/additional-input/additional-input-list-core.js
  • src/components/mui/formik-inputs/additional-input/meta-field-values.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/mui/formik-inputs/additional-input/additional-input-list-core.js
  • src/components/mui/tests/additional-input-list-core.test.js

Comment thread src/components/mui/__tests__/meta-field-values.test.js Outdated
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Comment thread src/components/mui/sortable-table-v2/mui-table-sortable-v2.js Outdated
Comment thread src/components/mui/sortable-table-v2/mui-table-sortable-v2.js Outdated

@smarcet smarcet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@tomrndom please review

…e tests

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
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.

4 participants