Skip to content

Commit

Permalink
馃 related #10143 not update dirty until interacted (#10157)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebill1049 committed Mar 21, 2023
1 parent c1cb992 commit 5292587
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/useFormState.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ describe('useFormState', () => {

fireEvent.click(screen.getByRole('button'));

expect(await screen.findByText('dirty')).toBeVisible();
expect(await screen.queryByText('dirty')).toBeNull();
expect(await screen.findByText('valid')).toBeVisible();
});

Expand Down
8 changes: 0 additions & 8 deletions src/useFormState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,6 @@ function useFormState<TFieldValues extends FieldValues = FieldValues>(

React.useEffect(() => {
_mounted.current = true;
const isDirty = control._proxyFormState.isDirty && control._getDirty();

if (isDirty !== control._formState.isDirty) {
control._subjects.state.next({
isDirty,
});
}

_localProxyFormState.current.isValid && control._updateValid(true);

return () => {
Expand Down

0 comments on commit 5292587

Please sign in to comment.