Skip to content

on-confirm-disabled-rename #3918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/flat-boats-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@twilio-paste/alert-dialog": patch
"@twilio-paste/core": patch
---

Changing the property name, onConfirmDisabled, in AlertDialog component. The property is called isConfirmDisabled. Non breaking change.
14 changes: 12 additions & 2 deletions packages/paste-core/components/alert-dialog/src/AlertDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,22 @@ export interface AlertDialogProps extends HTMLPasteProps<"div"> {
*/
onDismissLabel: string;
/**
* Disable the confirm button
* Disable the confirm button. Use isConfirmDisabled
* @deprecated This prop has been deprecated in favor of the `isConfirmDisabled` prop.
*
* @default false
* @type {boolean}
* @memberof AlertDialogProps
*/
onConfirmDisabled?: boolean;
/**
* Disable the confirm button
*
* @default false
* @type {boolean}
* @memberof AlertDialogProps
*/
isConfirmDisabled?: boolean;
/**
* Overrides the default element name to apply unique styles with the Customization Provider
*
Expand All @@ -105,6 +114,7 @@ export const AlertDialog = React.forwardRef<HTMLDivElement, AlertDialogProps>(
onDismiss,
onDismissLabel,
onConfirmDisabled,
isConfirmDisabled,
...props
},
ref,
Expand Down Expand Up @@ -143,7 +153,7 @@ export const AlertDialog = React.forwardRef<HTMLDivElement, AlertDialogProps>(
onDismissLabel={onDismissLabel}
onConfirm={onConfirm}
onConfirmLabel={onConfirmLabel}
onConfirmDisabled={onConfirmDisabled}
isConfirmDisabled={isConfirmDisabled || onConfirmDisabled}
/>
</Box>
</ModalDialogOverlay>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface AlertDialogFooterProps extends HTMLPasteProps<"div">, Pick<BoxP
onConfirmLabel: string;
onDismiss: () => void;
onDismissLabel: string;
isConfirmDisabled?: boolean;
/** @deprecated This prop has been deprecated in favor of the `isConfirmDisabled` prop. */
onConfirmDisabled?: boolean;
}

Expand All @@ -23,7 +25,8 @@ export const AlertDialogFooter = React.forwardRef<HTMLDivElement, AlertDialogFoo
onConfirmLabel,
onDismiss,
onDismissLabel,
onConfirmDisabled = false,
onConfirmDisabled,
isConfirmDisabled = onConfirmDisabled || false,
...props
},
ref,
Expand All @@ -47,7 +50,11 @@ export const AlertDialogFooter = React.forwardRef<HTMLDivElement, AlertDialogFoo
<Button variant="secondary" onClick={onDismiss}>
{onDismissLabel}
</Button>
<Button variant={primaryVariant} onClick={onConfirm} disabled={destructive && onConfirmDisabled}>
<Button
variant={primaryVariant}
onClick={onConfirm}
disabled={destructive && (isConfirmDisabled || onConfirmDisabled)}
>
{onConfirmLabel}
</Button>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const DisabledButtonDestructiveAlertDialog = ({ dialogIsOpen = false }):
onDismiss={handleDismiss}
onDismissLabel="Cancel"
destructive
onConfirmDisabled={isDisabled}
isConfirmDisabled={isDisabled}
>
You&apos;re about to delete &ldquo;Toyota TCB Automobile (Gevelsberg)&ldquo; and all data associated with it.
This regulatory bundle will be deleted immediately. You can&apos;t undo this action.
Expand Down
9 changes: 8 additions & 1 deletion packages/paste-core/components/alert-dialog/type-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,13 @@
"externalProp": true,
"description": "Specify that a standard HTML element should behave like a defined custom built-in element"
},
"isConfirmDisabled": {
"type": "boolean",
"defaultValue": false,
"required": false,
"externalProp": false,
"description": "Disable the confirm button"
},
"itemID": {
"type": "string",
"defaultValue": null,
Expand Down Expand Up @@ -723,7 +730,7 @@
"defaultValue": false,
"required": false,
"externalProp": false,
"description": "Disable the confirm button"
"description": "Disable the confirm button. Use isConfirmDisabled"
},
"onContextMenu": {
"type": "MouseEventHandler<HTMLDivElement>",
Expand Down
Loading