Skip to content

Commit

Permalink
fix(clerk-js): Allow to delete username if optional
Browse files Browse the repository at this point in the history
fix(clerk-js): Add changeset message

fix(clerk-js): Add changeset message

fix(clerk-js): Add changeset message
  • Loading branch information
raptisj committed Aug 11, 2023
1 parent 86b49c1 commit ac5a700
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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
---

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

0 comments on commit ac5a700

Please sign in to comment.