Skip to content

Commit 03045bd

Browse files
fix(site): fix dialog loading buttons displaying text over the spinner (#10501)
1 parent 01ceb84 commit 03045bd

File tree

5 files changed

+39
-13
lines changed

5 files changed

+39
-13
lines changed

site/src/components/Dialogs/ConfirmDialog/ConfirmDialog.stories.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,12 @@ export const SuccessDialogWithCancel: Story = {
5555
type: "success",
5656
},
5757
};
58+
59+
export const SuccessDialogLoading: Story = {
60+
args: {
61+
description: "I am successful.",
62+
hideCancel: true,
63+
type: "success",
64+
confirmLoading: true,
65+
},
66+
};

site/src/components/Dialogs/ConfirmDialog/ConfirmDialog.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ const CONFIRM_DIALOG_DEFAULTS: Record<
3232
};
3333

3434
export interface ConfirmDialogProps
35-
extends Omit<
36-
DialogActionButtonsProps,
37-
"color" | "confirmDialog" | "onCancel"
38-
> {
35+
extends Omit<DialogActionButtonsProps, "color" | "onCancel"> {
3936
readonly description?: ReactNode;
4037
/**
4138
* hideCancel hides the cancel button when set true, and shows the cancel
@@ -135,7 +132,6 @@ export const ConfirmDialog: FC<PropsWithChildren<ConfirmDialogProps>> = ({
135132
<DialogActions>
136133
<DialogActionButtons
137134
cancelText={cancelText}
138-
confirmDialog
139135
confirmLoading={confirmLoading}
140136
confirmText={confirmText || defaults.confirmText}
141137
disabled={disabled}

site/src/components/Dialogs/DeleteDialog/DeleteDialog.stories.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ const meta: Meta<typeof DeleteDialog> = {
1616
};
1717

1818
export default meta;
19+
1920
type Story = StoryObj<typeof DeleteDialog>;
2021

2122
const Example: Story = {};
2223

24+
export const Loading: Story = {
25+
args: {
26+
confirmLoading: true,
27+
},
28+
};
29+
2330
export { Example as DeleteDialog };

site/src/components/Dialogs/Dialog.tsx

+22-7
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ export interface DialogActionButtonsProps {
1212
confirmText?: ReactNode;
1313
/** Whether or not confirm is loading, also disables cancel when true */
1414
confirmLoading?: boolean;
15-
/** Whether or not this is a confirm dialog */
16-
confirmDialog?: boolean;
1715
/** Whether or not the submit button is disabled */
1816
disabled?: boolean;
1917
/** Called when cancel is clicked */
@@ -49,6 +47,7 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
4947
{cancelText}
5048
</LoadingButton>
5149
)}
50+
5251
{onConfirm && (
5352
<LoadingButton
5453
fullWidth
@@ -76,7 +75,10 @@ const styles = {
7675
"&.MuiButton-contained": {
7776
backgroundColor: colors.red[10],
7877
borderColor: colors.red[9],
79-
color: theme.palette.text.primary,
78+
79+
"&:not(.MuiLoadingButton-loading)": {
80+
color: theme.palette.text.primary,
81+
},
8082

8183
"&:hover:not(:disabled)": {
8284
backgroundColor: colors.red[9],
@@ -86,26 +88,39 @@ const styles = {
8688
"&.Mui-disabled": {
8789
backgroundColor: colors.red[15],
8890
borderColor: colors.red[15],
89-
color: colors.red[9],
91+
92+
"&:not(.MuiLoadingButton-loading)": {
93+
color: colors.red[9],
94+
},
9095
},
9196
},
9297
}),
9398
successButton: (theme) => ({
9499
"&.MuiButton-contained": {
95100
backgroundColor: theme.palette.success.main,
96-
color: theme.palette.primary.contrastText,
101+
102+
"&:not(.MuiLoadingButton-loading)": {
103+
color: theme.palette.primary.contrastText,
104+
},
105+
97106
"&:hover": {
98107
backgroundColor: theme.palette.success.dark,
108+
99109
"@media (hover: none)": {
100110
backgroundColor: "transparent",
101111
},
112+
102113
"&.Mui-disabled": {
103114
backgroundColor: "transparent",
104115
},
105116
},
117+
106118
"&.Mui-disabled": {
107-
backgroundColor: theme.palette.action.disabledBackground,
108-
color: theme.palette.text.secondary,
119+
backgroundColor: theme.palette.success.dark,
120+
121+
"&:not(.MuiLoadingButton-loading)": {
122+
color: theme.palette.text.secondary,
123+
},
109124
},
110125
},
111126

site/src/pages/TemplateSettingsPage/TemplateSchedulePage/ScheduleDialog.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ export const ScheduleDialog: FC<PropsWithChildren<ScheduleDialogProps>> = ({
118118
<DialogActions>
119119
<DialogActionButtons
120120
cancelText={cancelText}
121-
confirmDialog
122121
confirmLoading={confirmLoading}
123122
confirmText="Submit"
124123
disabled={disabled}

0 commit comments

Comments
 (0)