Skip to content

Commit

Permalink
🪡 related react-hook-form#10143 not update dirty until interacted (re…
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebill1049 authored and kylemclean committed Feb 2, 2024
1 parent d7223a0 commit 93fe441
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 93fe441

Please sign in to comment.