소스 검색

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

Michael Bromley 7 달 전
부모
커밋
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,