diff --git a/.changeset/slick-windows-listen.md b/.changeset/slick-windows-listen.md new file mode 100644 index 00000000000..09daf56e995 --- /dev/null +++ b/.changeset/slick-windows-listen.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Fixes issue where min/max username lengths errors were not properly interpolated within profile component. diff --git a/packages/clerk-js/src/ui/components/UserProfile/UsernameForm.tsx b/packages/clerk-js/src/ui/components/UserProfile/UsernameForm.tsx index c6f94e98778..8f6c004aaef 100644 --- a/packages/clerk-js/src/ui/components/UserProfile/UsernameForm.tsx +++ b/packages/clerk-js/src/ui/components/UserProfile/UsernameForm.tsx @@ -1,10 +1,10 @@ import { useReverification, useUser } from '@clerk/shared/react'; import { useEnvironment } from '../../contexts'; -import { localizationKeys } from '../../customizables'; +import { localizationKeys, useLocalizations } from '../../customizables'; import type { FormProps } from '../../elements'; import { Form, FormButtons, FormContainer, useCardState, withCardStateProvider } from '../../elements'; -import { handleError, useFormControl } from '../../utils'; +import { createUsernameError, handleError, useFormControl } from '../../utils'; type UsernameFormProps = FormProps; @@ -16,10 +16,13 @@ export const UsernameForm = withCardStateProvider((props: UsernameFormProps) => const { userSettings } = useEnvironment(); const card = useCardState(); + const { t, locale } = useLocalizations(); + const { usernameSettings } = userSettings; const usernameField = useFormControl('username', user?.username || '', { type: 'text', label: localizationKeys('formFieldLabel__username'), placeholder: localizationKeys('formFieldInputPlaceholder__username'), + buildErrorMessage: errors => createUsernameError(errors, { t, locale, usernameSettings }), }); if (!user) {