Skip to content

Commit ce2b2f3

Browse files
committed
fix story with form error
1 parent cf632d5 commit ce2b2f3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.stories.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,7 @@ CreateWorkspaceError.args = {
106106
],
107107
}),
108108
},
109+
initialTouched: {
110+
name: true,
111+
},
109112
}

site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { makeStyles } from "@material-ui/core/styles"
22
import TextField from "@material-ui/core/TextField"
33
import { ErrorSummary } from "components/ErrorSummary/ErrorSummary"
4-
import { FormikContextType, useFormik } from "formik"
4+
import { FormikContextType, FormikTouched, useFormik } from "formik"
55
import { FC, useState } from "react"
66
import * as Yup from "yup"
77
import * as TypesGen from "../../api/typesGenerated"
@@ -35,6 +35,8 @@ export interface CreateWorkspacePageViewProps {
3535
createWorkspaceErrors: Partial<Record<CreateWorkspaceErrors, Error | unknown>>
3636
onCancel: () => void
3737
onSubmit: (req: TypesGen.CreateWorkspaceRequest) => void
38+
// initialTouched is only used for testing the error state of the form.
39+
initialTouched?: FormikTouched<TypesGen.CreateWorkspaceRequest>
3840
}
3941

4042
export const validationSchema = Yup.object({
@@ -53,6 +55,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = (props)
5355
},
5456
enableReinitialize: true,
5557
validationSchema,
58+
initialTouched: props.initialTouched,
5659
onSubmit: (request) => {
5760
if (!props.templateSchema) {
5861
throw new Error("No template schema loaded")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy