Skip to content

Commit 25a94bd

Browse files
authored
fix(web): sign up double click (#21349)
1 parent 76eaee3 commit 25a94bd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

web/src/routes/auth/register/+page.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
let password = $state('');
1414
let confirmPassword = $state('');
1515
let name = $state('');
16+
let loading = $state(false);
1617
let errorMessage = $derived(
1718
password === confirmPassword || confirmPassword.length === 0 ? '' : $t('password_does_not_match'),
1819
);
@@ -27,10 +28,11 @@
2728
const onSubmit = async (event: Event) => {
2829
event.preventDefault();
2930
30-
if (!valid) {
31+
if (!valid || loading) {
3132
return;
3233
}
3334
35+
loading = true;
3436
errorMessage = '';
3537
3638
try {
@@ -40,6 +42,8 @@
4042
} catch (error) {
4143
handleError(error, $t('errors.unable_to_create_admin_account'));
4244
errorMessage = $t('errors.unable_to_create_admin_account');
45+
} finally {
46+
loading = false;
4347
}
4448
};
4549
</script>
@@ -70,6 +74,8 @@
7074
<Alert color="danger" title={errorMessage} size="medium" class="mt-4" />
7175
{/if}
7276

73-
<Button class="mt-4" type="submit" size="giant" shape="round" fullWidth disabled={!valid}>{$t('sign_up')}</Button>
77+
<Button class="mt-4" type="submit" size="giant" shape="round" fullWidth disabled={!valid || loading} {loading}
78+
>{$t('sign_up')}</Button
79+
>
7480
</form>
7581
</AuthPageLayout>

0 commit comments

Comments
 (0)