Skip to content

Commit

Permalink
fix(clerk-js): Add createUsernameError to sign-up continue flow (#4840)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcarpenter authored Jan 6, 2025
1 parent 1f8907b commit 3e5250e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/rotten-berries-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Fix username field error message rendering within sign-up continue flow.
9 changes: 6 additions & 3 deletions packages/clerk-js/src/ui/components/SignUp/SignUpContinue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useClerk } from '@clerk/shared/react';
import React, { useEffect, useMemo } from 'react';

import { SignInContext, useCoreSignUp, useEnvironment, useOptions, useSignUpContext } from '../../contexts';
import { descriptors, Flex, Flow, localizationKeys } from '../../customizables';
import { descriptors, Flex, Flow, localizationKeys, useLocalizations } from '../../customizables';
import {
Card,
Header,
Expand All @@ -13,7 +13,7 @@ import {
import { useCardState } from '../../elements/contexts';
import { useRouter } from '../../router';
import type { FormControlState } from '../../utils';
import { buildRequest, handleError, useFormControl } from '../../utils';
import { buildRequest, createUsernameError, handleError, useFormControl } from '../../utils';
import { SignUpForm } from './SignUpForm';
import type { ActiveIdentifier } from './signUpFormHelpers';
import {
Expand All @@ -30,7 +30,8 @@ function _SignUpContinue() {
const clerk = useClerk();
const { navigate } = useRouter();
const { displayConfig, userSettings } = useEnvironment();
const { attributes } = userSettings;
const { attributes, usernameSettings } = userSettings;
const { t, locale } = useLocalizations();
const { afterSignUpUrl, signInUrl, unsafeMetadata, initialValues = {} } = useSignUpContext();
const signUp = useCoreSignUp();
const options = useOptions();
Expand Down Expand Up @@ -62,6 +63,8 @@ function _SignUpContinue() {
type: 'text',
label: localizationKeys('formFieldLabel__username'),
placeholder: localizationKeys('formFieldInputPlaceholder__username'),
transformer: value => value.trim(),
buildErrorMessage: errors => createUsernameError(errors, { t, locale, usernameSettings }),
}),
phoneNumber: useFormControl('phoneNumber', initialValues.phoneNumber || '', {
type: 'tel',
Expand Down

0 comments on commit 3e5250e

Please sign in to comment.