Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/red-deers-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---
Comment thread
raptisj marked this conversation as resolved.

Fix a bug where it was not possible to delete the username if it was optional.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { useWizard, Wizard } from '../../common';
import { useCoreUser } from '../../contexts';
import { useCoreUser, useEnvironment } from '../../contexts';
import { localizationKeys } from '../../customizables';
import { ContentPage, Form, FormButtons, SuccessPage, useCardState, withCardStateProvider } from '../../elements';
import { handleError, useFormControl } from '../../utils';
import { UserProfileBreadcrumbs } from './UserProfileNavbar';

export const UsernamePage = withCardStateProvider(() => {
const user = useCoreUser();
const { userSettings } = useEnvironment();
const card = useCardState();
const wizard = useWizard();
const usernameField = useFormControl('username', user.username || '', {
Expand All @@ -15,7 +16,10 @@ export const UsernamePage = withCardStateProvider(() => {
placeholder: localizationKeys('formFieldInputPlaceholder__username'),
});

const canSubmit = usernameField.value.length > 1 && user.username !== usernameField.value;
const isUsernameRequired = userSettings.attributes.username.required;

const canSubmit =
(isUsernameRequired ? usernameField.value.length > 1 : true) && user.username !== usernameField.value;

const updatePassword = async () => {
try {
Expand Down