From 6dea273044bbf3843724d19a95c3b694c1dbbab8 Mon Sep 17 00:00:00 2001 From: Javier Ruiz Date: Thu, 31 Aug 2023 10:22:07 +0100 Subject: [PATCH] Grafana/ui: Expose trigger method from `useForm` to children (#73831) Form: Expose trigger method from useForm to children --- packages/grafana-ui/src/components/Forms/Form.tsx | 2 +- packages/grafana-ui/src/types/forms.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/grafana-ui/src/components/Forms/Form.tsx b/packages/grafana-ui/src/components/Forms/Form.tsx index c46e20358a7..d0362bd0824 100644 --- a/packages/grafana-ui/src/components/Forms/Form.tsx +++ b/packages/grafana-ui/src/components/Forms/Form.tsx @@ -46,7 +46,7 @@ export function Form({ onSubmit={handleSubmit(onSubmit)} {...htmlProps} > - {children({ errors: formState.errors, formState, ...rest })} + {children({ errors: formState.errors, formState, trigger, ...rest })} ); } diff --git a/packages/grafana-ui/src/types/forms.ts b/packages/grafana-ui/src/types/forms.ts index c5451524c95..86e5869c861 100644 --- a/packages/grafana-ui/src/types/forms.ts +++ b/packages/grafana-ui/src/types/forms.ts @@ -1,7 +1,7 @@ import { UseFormReturn, FieldValues, FieldErrors, FieldArrayMethodProps } from 'react-hook-form'; export type { SubmitHandler as FormsOnSubmit, FieldErrors as FormFieldErrors } from 'react-hook-form'; -export type FormAPI = Omit, 'trigger' | 'handleSubmit'> & { +export type FormAPI = Omit, 'handleSubmit'> & { errors: FieldErrors; };