Skip to content

Commit 2cdf9ef

Browse files
Fix account deletion modal (#18892)
1 parent 6dcf2d8 commit 2cdf9ef

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

components/dashboard/src/components/ConfirmationModal.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ export const ConfirmationModal: FC<Props> = ({
4747
}, [onConfirm]);
4848

4949
return (
50-
<Modal visible={visible === undefined ? true : visible} onClose={onClose} onSubmit={handleSubmit}>
50+
<Modal
51+
visible={visible === undefined ? true : visible}
52+
onClose={onClose}
53+
onSubmit={handleSubmit}
54+
disabled={buttonDisabled}
55+
>
5156
<ModalHeader>{title}</ModalHeader>
5257
<ModalBody>
5358
{warningText && (

components/dashboard/src/components/Modal.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Props = {
2828
autoFocus?: boolean;
2929
disableFocusLock?: boolean;
3030
className?: string;
31+
disabled?: boolean;
3132
onClose: () => void;
3233
onSubmit?: () => void | Promise<void>;
3334
};
@@ -42,6 +43,7 @@ export const Modal: FC<Props> = ({
4243
autoFocus = false,
4344
disableFocusLock = false,
4445
className,
46+
disabled = false,
4547
onClose,
4648
onSubmit,
4749
}) => {
@@ -103,7 +105,7 @@ export const Modal: FC<Props> = ({
103105
aria-labelledby="modal-header"
104106
tabIndex={-1}
105107
>
106-
<MaybeWithForm onSubmit={onSubmit}>
108+
<MaybeWithForm onSubmit={onSubmit} disabled={disabled}>
107109
{closeable && <ModalCloseIcon onClose={() => closeModal("x")} />}
108110
{title ? (
109111
<>
@@ -127,8 +129,9 @@ export default Modal;
127129

128130
type MaybeWithFormProps = {
129131
onSubmit: Props["onSubmit"];
132+
disabled: Props["disabled"];
130133
};
131-
const MaybeWithForm: FC<MaybeWithFormProps> = ({ onSubmit, children }) => {
134+
const MaybeWithForm: FC<MaybeWithFormProps> = ({ onSubmit, disabled, children }) => {
132135
const handleSubmit = useCallback(
133136
(e: FormEvent) => {
134137
e.preventDefault();
@@ -147,7 +150,7 @@ const MaybeWithForm: FC<MaybeWithFormProps> = ({ onSubmit, children }) => {
147150
return (
148151
<form onSubmit={handleSubmit}>
149152
{/* including a hidden submit button ensures submit on enter works despite a button w/ type="submit" existing or not */}
150-
<input type="submit" className="hidden" hidden />
153+
<input type="submit" className="hidden" hidden disabled={disabled} />
151154
{children}
152155
</form>
153156
);

0 commit comments

Comments
 (0)