From 4df3aca805bb0dd0727166623a781d58b2076ae0 Mon Sep 17 00:00:00 2001 From: Jimmy Domagala-Tang Date: Wed, 9 Jul 2025 13:27:45 -0700 Subject: [PATCH] fix: prevent users spam clicking from creating multiple projects (#26818) GitOrigin-RevId: 8e867d02df70424f710b101e23e0889101e31d72 --- .../new-project-button/modal-content-new-project-form.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/features/project-list/components/new-project-button/modal-content-new-project-form.tsx b/services/web/frontend/js/features/project-list/components/new-project-button/modal-content-new-project-form.tsx index 13e0458127..5f03416a39 100644 --- a/services/web/frontend/js/features/project-list/components/new-project-button/modal-content-new-project-form.tsx +++ b/services/web/frontend/js/features/project-list/components/new-project-button/modal-content-new-project-form.tsx @@ -38,6 +38,7 @@ function ModalContentNewProjectForm({ onCancel, template = 'none' }: Props) { const { t } = useTranslation() const { autoFocusedRef } = useRefWithAutoFocus() const [projectName, setProjectName] = useState('') + const [redirecting, setRedirecting] = useState(false) const { isLoading, isError, error, runAsync } = useAsync() const location = useLocation() @@ -52,6 +53,8 @@ function ModalContentNewProjectForm({ onCancel, template = 'none' }: Props) { ) .then(data => { if (data.project_id) { + // prevents clicking on create again between async load of next page and pending state being finished + setRedirecting(true) location.assign(`/project/${data.project_id}`) } }) @@ -100,7 +103,7 @@ function ModalContentNewProjectForm({ onCancel, template = 'none' }: Props) { {t('create')}