Skip to content

fix: Change Delete button to CONFIRM#810

Open
priscila-moneo wants to merge 1 commit intomasterfrom
fix/change-delete-button-to-confirm
Open

fix: Change Delete button to CONFIRM#810
priscila-moneo wants to merge 1 commit intomasterfrom
fix/change-delete-button-to-confirm

Conversation

@priscila-moneo
Copy link

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

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

image
  • Extended the reusable table API in mui-table.js to support per-use customization of delete confirmation button text (deleteDialogConfirmText) and color (confirmButtonColor), while keeping defaults.
  • Applied the customization only to the delete request action inside Sponsors Users Access Request flow in request-table.js: button text is "Confirm" and color is primary.

Summary by CodeRabbit

  • New Features
    • Added customizable confirmation text option for delete dialog buttons, allowing override of default translated strings.
    • Confirmation buttons now support custom colors with automatic theme-aware contrast adjustment and hover state styling.

@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

The PR adds customization capabilities for delete confirmation dialogs by introducing dynamic styling for confirm buttons and exposing new props to configure confirmation text and button color across components using MuiTable.

Changes

Cohort / File(s) Summary
Confirm Dialog Styling
src/components/mui/confirm-dialog.js
Implements dynamic styling hook for confirm button; applies augmented color theming (background, contrast text, hover state) when confirmButtonColor is a hex string, otherwise remains unstyled.
MuiTable Props Expansion
src/components/mui/table/mui-table.js
Exposes two new public props (deleteDialogConfirmText, confirmButtonColor) for delete dialog customization; adds conditional defaults to use provided values or fallback to existing defaults.
Request Table Integration
src/pages/sponsors/sponsor-users-list-page/components/request-table.js
Applies new MuiTable props to configure delete confirmation dialog with custom text and button color styling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • smarcet
  • romanetar

Poem

🐰 With dialogs dressed in custom hues,
Confirmations now sing the blues (and reds, and greens!),
Hex colors augment with flair,
Delete buttons beyond compare! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title partially captures the main change: it mentions changing the delete button to 'CONFIRM', but omits the key customization feature—extending MuiTable's API to support configurable button text and color via new props.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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/change-delete-button-to-confirm

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 force-pushed the fix/change-delete-button-to-confirm branch from 0a2e9c2 to be33b82 Compare March 4, 2026 19:48
@priscila-moneo priscila-moneo marked this pull request as ready for review March 4, 2026 20:01
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.

Actionable comments posted: 1

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

88-90: Consider nullish coalescing for fallback semantics.

Using ?? avoids treating intentionally empty strings as missing values.

Proposed tweak
-      confirmButtonColor: confirmButtonColor || "error",
+      confirmButtonColor: confirmButtonColor ?? "error",
       confirmButtonText:
-        deleteDialogConfirmText || T.translate("general.yes_delete")
+        deleteDialogConfirmText ?? T.translate("general.yes_delete")
🤖 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 88 - 90, The fallback
logic for confirmButtonColor and confirmButtonText uses || which treats empty
strings as missing; update the assignments in the component (confirmButtonColor
and confirmButtonText derived from deleteDialogConfirmText and T.translate) to
use the nullish coalescing operator (??) so only null or undefined fall back
(e.g., confirmButtonColor = confirmButtonColor ?? "error" and confirmButtonText
= deleteDialogConfirmText ?? T.translate("general.yes_delete")).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/mui/confirm-dialog.js`:
- Around line 60-78: The Button is receiving confirmButtonColor even when it may
be a hex string which violates the MUI v6 Button.color API; update the
ConfirmDialog Button rendering so that the color prop is only set when
confirmButtonColor is a palette key (non-hex), e.g. set color={typeof
confirmButtonColor==="string" && !confirmButtonColor.startsWith("#") ?
confirmButtonColor : undefined}, and keep the existing sx augmentation block to
apply hex colors (augmentColor logic) only when confirmButtonColor
startsWith("#"); ensure you reference the confirmButtonColor prop and the
Button's color and sx props in this change.

---

Nitpick comments:
In `@src/components/mui/table/mui-table.js`:
- Around line 88-90: The fallback logic for confirmButtonColor and
confirmButtonText uses || which treats empty strings as missing; update the
assignments in the component (confirmButtonColor and confirmButtonText derived
from deleteDialogConfirmText and T.translate) to use the nullish coalescing
operator (??) so only null or undefined fall back (e.g., confirmButtonColor =
confirmButtonColor ?? "error" and confirmButtonText = deleteDialogConfirmText ??
T.translate("general.yes_delete")).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d757365a-1bf2-4245-8a19-695bebc31b5d

📥 Commits

Reviewing files that changed from the base of the PR and between 4798a75 and be33b82.

📒 Files selected for processing (3)
  • src/components/mui/confirm-dialog.js
  • src/components/mui/table/mui-table.js
  • src/pages/sponsors/sponsor-users-list-page/components/request-table.js

Comment on lines +60 to +78
color={confirmButtonColor}
sx={
typeof confirmButtonColor === "string" &&
confirmButtonColor.startsWith("#")
? (theme) => {
const augmentedColor = theme.palette.augmentColor({
color: { main: confirmButtonColor }
});

return {
backgroundColor: augmentedColor.main,
color: augmentedColor.contrastText,
"&:hover": {
backgroundColor: augmentedColor.dark
}
};
}
: undefined
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

MUI v6 Material-UI Button color prop hex string support documentation

💡 Result:

MUI v6 <Button color={...}> does not document support for passing a raw hex value (for example color="#ff0000"). The Button API documents color as a set of theme palette keys ('primary' | 'secondary' | 'success' | ...')—with string intended for theme-extended custom color names, not arbitrary CSS colors. [1]

If you want a hex-based color, the documented approaches are:

  • Put the hex in the theme palette (tokens like main, light, dark, contrastText support hex/rgb/hsl), then use that palette key via color="yourColorName" (with TS module augmentation for the color prop). [2]
  • Style the button directly (for example via sx={{ bgcolor: '#ff0000' }} / sx={{ color: '#fff' }}), rather than using the color prop. (This is implied by color being palette-key-based in the API.) [1]

References

  1. MUI v6 Button API (color prop types and description) — https://mui.com/material-ui/api/button/
  2. MUI v6 Palette customization (custom colors, supported formats, using in components, TS overrides) — https://mui.com/material-ui/customization/palette/

Do not pass hex values through Button.color—it violates the MUI v6 API contract.

MUI v6 Button's color prop officially supports palette keys only ('primary', 'secondary', etc.), not arbitrary hex strings. Line 60 passes confirmButtonColor to color, which may be a hex string, contradicting the documented API. The correct approach is to apply hex styling exclusively via sx when detected, leaving color undefined for non-palette values.

Proposed refactor
+const isHexConfirmColor =
+  typeof confirmButtonColor === "string" &&
+  confirmButtonColor.startsWith("#");
...
       <Button
         fullWidth
         onClick={onConfirm}
         variant="contained"
-        color={confirmButtonColor}
+        color={isHexConfirmColor ? undefined : confirmButtonColor}
         sx={
-          typeof confirmButtonColor === "string" &&
-          confirmButtonColor.startsWith("#")
+          isHexConfirmColor
             ? (theme) => {
                 const augmentedColor = theme.palette.augmentColor({
                   color: { main: confirmButtonColor }
                 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/mui/confirm-dialog.js` around lines 60 - 78, The Button is
receiving confirmButtonColor even when it may be a hex string which violates the
MUI v6 Button.color API; update the ConfirmDialog Button rendering so that the
color prop is only set when confirmButtonColor is a palette key (non-hex), e.g.
set color={typeof confirmButtonColor==="string" &&
!confirmButtonColor.startsWith("#") ? confirmButtonColor : undefined}, and keep
the existing sx augmentation block to apply hex colors (augmentColor logic) only
when confirmButtonColor startsWith("#"); ensure you reference the
confirmButtonColor prop and the Button's color and sx props in this change.

@priscila-moneo priscila-moneo force-pushed the fix/change-delete-button-to-confirm branch from be33b82 to 3b81d8b Compare March 4, 2026 21:21
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