Skip to content

Commit eeb29ca

Browse files
committed
refactor: allow helperText in getFormHelpers
By passing in helperText, we will not accidentally overwrite it.
1 parent dbd5b4a commit eeb29ca

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

site/src/util/formUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface FormHelpers {
1313

1414
export const getFormHelpers =
1515
<T>(form: FormikContextType<T>, formErrors?: FormikErrors<T>) =>
16-
(name: keyof T): FormHelpers => {
16+
(name: keyof T, helperText = ""): FormHelpers => {
1717
if (typeof name !== "string") {
1818
throw new Error(`name must be type of string, instead received '${typeof name}'`)
1919
}
@@ -28,7 +28,7 @@ export const getFormHelpers =
2828
...form.getFieldProps(name),
2929
id: name,
3030
error: touched && Boolean(error),
31-
helperText: touched && error,
31+
helperText: touched ? error : helperText,
3232
}
3333
}
3434

0 commit comments

Comments
 (0)