Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7f32600

Browse files
committed
Fix forms
1 parentbbf2152 commit7f32600

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

‎site/src/components/Form/index.ts‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{FormikContextType,FormikErrors,getIn}from"formik"
1+
import{FormikContextType,getIn}from"formik"
22
import{ChangeEvent,ChangeEventHandler,FocusEventHandler}from"react"
33

44
export*from"./FormCloseButton"
@@ -17,17 +17,10 @@ interface FormHelpers {
1717
helperText?:string
1818
}
1919

20-
exportconstgetFormHelpers=<T>(
21-
form:FormikContextType<T>,
22-
name:string,
23-
additionalErrors:FormikErrors<T>={},
24-
):FormHelpers=>{
20+
exportconstgetFormHelpers=<T>(form:FormikContextType<T>,name:string,error?:string):FormHelpers=>{
2521
// getIn is a util function from Formik that gets at any depth of nesting, and is necessary for the types to work
2622
consttouched=getIn(form.touched,name)
27-
consterrors={
28-
...getIn(form.errors,name),
29-
...additionalErrors,
30-
}
23+
consterrors=error??getIn(form.errors,name)
3124
return{
3225
...form.getFieldProps(name),
3326
id:name,

‎site/src/components/Preferences/AccountForm.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,23 @@ export const AccountForm: React.FC<AccountFormProps> = ({
5555
<formonSubmit={form.handleSubmit}>
5656
<Stack>
5757
<TextField
58-
{...getFormHelpers<AccountFormValues>(form,"name",formErrors)}
58+
{...getFormHelpers<AccountFormValues>(form,"name")}
5959
autoFocus
6060
autoComplete="name"
6161
fullWidth
6262
label={Language.nameLabel}
6363
variant="outlined"
6464
/>
6565
<TextField
66-
{...getFormHelpers<AccountFormValues>(form,"email",formErrors)}
66+
{...getFormHelpers<AccountFormValues>(form,"email",formErrors.email)}
6767
onChange={onChangeTrimmed(form)}
6868
autoComplete="email"
6969
fullWidth
7070
label={Language.emailLabel}
7171
variant="outlined"
7272
/>
7373
<TextField
74-
{...getFormHelpers<AccountFormValues>(form,"username",formErrors)}
74+
{...getFormHelpers<AccountFormValues>(form,"username",formErrors.username)}
7575
onChange={onChangeTrimmed(form)}
7676
autoComplete="username"
7777
fullWidth

‎site/src/pages/preferences/account.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe("PreferencesAccountPage", () => {
3636
})
3737

3838
describe("when it is a success",()=>{
39-
it.only("shows the success message",async()=>{
39+
it("shows the success message",async()=>{
4040
jest.spyOn(API,"updateProfile").mockImplementationOnce((userId,data)=>
4141
Promise.resolve({
4242
id:userId,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp