Просмотр исходного кода

fix(dashboard): Fix issue with form not being marked dirty until second interaction

Michael Bromley 7 месяцев назад
Родитель
Сommit
604cf4fdad
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      packages/dashboard/src/lib/framework/page/use-detail-page.ts

+ 7 - 0
packages/dashboard/src/lib/framework/page/use-detail-page.ts

@@ -288,6 +288,13 @@ export function useDetailPage<
         },
     });
 
+    // A kind of ridiculous workaround to ensure that the `isDirty` and `isValid` properties
+    // are always up-to-date when used by the consuming component. This seems to be necessary
+    // due to the way that `react-hook-form` uses a Proxy object for the form state.
+    // See https://react-hook-form.com/docs/useform/formstate
+    // noinspection JSUnusedLocalSymbols
+    const { isDirty, isValid } = form.formState;
+
     return {
         form: form as any,
         submitHandler,