Skip to content

Commit 22a6eca

Browse files
committed
use a toast vs. disabling button when there's an error
1 parent 55bc734 commit 22a6eca

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

components/dashboard/src/repositories/detail/RepositoryName.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export const RepositoryNameForm: FC<Props> = ({ project }) => {
2828
async (e: React.FormEvent) => {
2929
e.preventDefault();
3030

31+
if (!nameError.isValid) {
32+
toast("Please correct the errors with the name.");
33+
return;
34+
}
35+
3136
updateProject.mutate(
3237
{
3338
id: project.id,
@@ -40,7 +45,7 @@ export const RepositoryNameForm: FC<Props> = ({ project }) => {
4045
},
4146
);
4247
},
43-
[updateProject, project.id, projectName, toast],
48+
[nameError.isValid, updateProject, project.id, projectName, toast],
4449
);
4550

4651
return (
@@ -53,11 +58,10 @@ export const RepositoryNameForm: FC<Props> = ({ project }) => {
5358
onBlur={nameError.onBlur}
5459
/>
5560

56-
{/* Don't disable button, just handle error and message */}
5761
<Button
5862
className="mt-4"
5963
htmlType="submit"
60-
disabled={project.name === projectName || !nameError.isValid}
64+
disabled={project.name === projectName}
6165
loading={updateProject.isLoading}
6266
>
6367
Update Name

0 commit comments

Comments
 (0)