Skip to content

Commit 4edb776

Browse files
authoredNov 6, 2023
chore(clerk-js): Replace text and email fields with Form.PlainInput (#2036)
* chore(clerk-js): Replace text and email fields with Form.PlainInput * chore(clerk-js): Localize the placeholder of the confirmation field when deleting a user account
1 parent c22cd52 commit 4edb776

File tree

10 files changed

+34
-31
lines changed

10 files changed

+34
-31
lines changed
 

‎.changeset/metal-cougars-fail.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Replace Form.Control with Form.PlainInput for text and email inputs.

‎.changeset/pretty-months-greet.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/localizations': patch
3+
'@clerk/clerk-js': patch
4+
'@clerk/types': patch
5+
---
6+
7+
Localize placeholder of confirmation field when deleting a user account from `<UserProfile/>`.

‎packages/clerk-js/src/ui/components/CreateOrganization/CreateOrganizationForm.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,21 @@ export const CreateOrganizationForm = (props: CreateOrganizationFormProps) => {
123123
onAvatarRemove={file ? onAvatarRemove : null}
124124
/>
125125
<Form.ControlRow elementId={nameField.id}>
126-
<Form.Control
127-
sx={{ flexBasis: '80%' }}
128-
autoFocus
126+
<Form.PlainInput
129127
{...nameField.props}
128+
sx={{ flexBasis: '80%' }}
130129
onChange={onChangeName}
131-
required
130+
isRequired
131+
autoFocus
132132
/>
133133
</Form.ControlRow>
134134
<Form.ControlRow elementId={slugField.id}>
135-
<Form.Control
136-
sx={{ flexBasis: '80%' }}
135+
<Form.PlainInput
137136
{...slugField.props}
138-
onChange={onChangeSlug}
137+
sx={{ flexBasis: '80%' }}
139138
icon={QuestionMark}
140-
required
139+
onChange={onChangeSlug}
140+
isRequired
141141
/>
142142
</Form.ControlRow>
143143
<FormButtonContainer>

‎packages/clerk-js/src/ui/components/OrganizationProfile/ActionConfirmationPage.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,7 @@ const ActionConfirmationPage = withCardStateProvider((props: ActionConfirmationP
141141
<Text localizationKey={actionDescription} />
142142

143143
<Form.ControlRow elementId={confirmationField.id}>
144-
<Form.Control
145-
{...confirmationField.props}
146-
required
147-
/>
144+
<Form.PlainInput {...confirmationField.props} />
148145
</Form.ControlRow>
149146

150147
<FormButtonContainer>

‎packages/clerk-js/src/ui/components/OrganizationProfile/ProfileSettingsPage.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export const ProfileSettingsPage = withCardStateProvider(() => {
3737
const dataChanged = organization.name !== nameField.value || organization.slug !== slugField.value;
3838
const canSubmit = (dataChanged || avatarChanged) && slugField.feedbackType !== 'error';
3939

40-
// eslint-disable-next-line @typescript-eslint/require-await
4140
const onSubmit = async (e: React.FormEvent) => {
4241
e.preventDefault();
4342
return (dataChanged ? organization.update({ name: nameField.value, slug: slugField.value }) : Promise.resolve())
@@ -90,17 +89,16 @@ export const ProfileSettingsPage = withCardStateProvider(() => {
9089
onAvatarRemove={isDefaultImage(organization.imageUrl) ? null : onAvatarRemove}
9190
/>
9291
<Form.ControlRow elementId={nameField.id}>
93-
<Form.Control
92+
<Form.PlainInput
9493
{...nameField.props}
9594
autoFocus
96-
required
95+
isRequired
9796
/>
9897
</Form.ControlRow>
9998
<Form.ControlRow elementId={slugField.id}>
100-
<Form.Control
99+
<Form.PlainInput
101100
{...slugField.props}
102101
onChange={onChangeSlug}
103-
required
104102
/>
105103
</Form.ControlRow>
106104
<FormButtons isDisabled={!canSubmit} />

‎packages/clerk-js/src/ui/components/UserProfile/DeletePage.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const DeletePage = withCardStateProvider(() => {
2929
type: 'text',
3030
label: localizationKeys('formFieldLabel__confirmDeletion'),
3131
isRequired: true,
32-
placeholder: 'Delete account',
32+
placeholder: localizationKeys('formFieldInputPlaceholder__confirmDeletionUserAccount'),
3333
});
3434

3535
const canSubmit = confirmationField.value === 'Delete account';
@@ -45,10 +45,7 @@ export const DeletePage = withCardStateProvider(() => {
4545
<Text localizationKey={localizationKeys('userProfile.deletePage.actionDescription')} />
4646

4747
<Form.ControlRow elementId={confirmationField.id}>
48-
<Form.Control
49-
{...confirmationField.props}
50-
required
51-
/>
48+
<Form.PlainInput {...confirmationField.props} />
5249
</Form.ControlRow>
5350
<FormButtons
5451
submitLabel={localizationKeys('userProfile.deletePage.confirm')}

‎packages/clerk-js/src/ui/components/UserProfile/EmailPage.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export const EmailPage = withCardStateProvider(() => {
3737

3838
const canSubmit = emailField.value.length > 1 && user.username !== emailField.value;
3939

40-
// eslint-disable-next-line @typescript-eslint/require-await
4140
const addEmail = async (e: React.FormEvent) => {
4241
e.preventDefault();
4342
return user
@@ -57,9 +56,8 @@ export const EmailPage = withCardStateProvider(() => {
5756
>
5857
<Form.Root onSubmit={addEmail}>
5958
<Form.ControlRow elementId={emailField.id}>
60-
<Form.Control
59+
<Form.PlainInput
6160
{...emailField.props}
62-
required
6361
autoFocus
6462
/>
6563
</Form.ControlRow>

‎packages/clerk-js/src/ui/components/UserProfile/ProfilePage.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ export const ProfilePage = withCardStateProvider(() => {
3434
type: 'text',
3535
label: localizationKeys('formFieldLabel__firstName'),
3636
placeholder: localizationKeys('formFieldInputPlaceholder__firstName'),
37+
isRequired: last_name.required,
3738
});
3839
const lastNameField = useFormControl('lastName', user.lastName || '', {
3940
type: 'text',
4041
label: localizationKeys('formFieldLabel__lastName'),
4142
placeholder: localizationKeys('formFieldInputPlaceholder__lastName'),
43+
isRequired: last_name.required,
4244
});
4345

4446
const userInfoChanged =
@@ -51,7 +53,6 @@ export const ProfilePage = withCardStateProvider(() => {
5153

5254
const nameEditDisabled = user.samlAccounts.some(sa => sa.active);
5355

54-
// eslint-disable-next-line @typescript-eslint/require-await
5556
const onSubmit = async (e: React.FormEvent) => {
5657
e.preventDefault();
5758

@@ -104,19 +105,17 @@ export const ProfilePage = withCardStateProvider(() => {
104105
/>
105106
{showFirstName && (
106107
<Form.ControlRow elementId={firstNameField.id}>
107-
<Form.Control
108-
autoFocus
108+
<Form.PlainInput
109109
{...firstNameField.props}
110-
required={first_name.required}
111110
isDisabled={nameEditDisabled}
111+
autoFocus
112112
/>
113113
</Form.ControlRow>
114114
)}
115115
{showLastName && (
116116
<Form.ControlRow elementId={lastNameField.id}>
117-
<Form.Control
117+
<Form.PlainInput
118118
{...lastNameField.props}
119-
required={last_name.required}
120119
isDisabled={nameEditDisabled}
121120
/>
122121
</Form.ControlRow>

‎packages/localizations/src/en-US.ts

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export const enUS: LocalizationResource = {
5959
formFieldInputPlaceholder__organizationSlug: '',
6060
formFieldInputPlaceholder__organizationDomain: '',
6161
formFieldInputPlaceholder__organizationDomainEmailAddress: '',
62+
formFieldInputPlaceholder__confirmDeletionUserAccount: 'Delete account',
6263
formFieldError__notMatchingPasswords: `Passwords don't match.`,
6364
formFieldError__matchingPasswords: 'Passwords match.',
6465
formFieldError__verificationLinkExpired: 'The verification link expired. Please request a new link.',

‎packages/types/src/localization.ts

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ type _LocalizationResource = {
8484
formFieldInputPlaceholder__organizationSlug: LocalizationValue;
8585
formFieldInputPlaceholder__organizationDomain: LocalizationValue;
8686
formFieldInputPlaceholder__organizationDomainEmailAddress: LocalizationValue;
87+
formFieldInputPlaceholder__confirmDeletionUserAccount: LocalizationValue;
8788
formFieldError__notMatchingPasswords: LocalizationValue;
8889
formFieldError__matchingPasswords: LocalizationValue;
8990
formFieldError__verificationLinkExpired: LocalizationValue;

0 commit comments

Comments
 (0)
Please sign in to comment.