refine icon indicating copy to clipboard operation
refine copied to clipboard

[BUG] @refinedev/react-hook-form useForm not detecting changes correctly

Open pcfreak30 opened this issue 1 year ago • 4 comments

Describe the bug

I have been debugging the functionality for warnWhenUnsavedChanges and I found that react-hook-form only ever emits a type with subscription event objects on blur?

At https://github.com/refinedev/refine/blob/master/packages/react-hook-form/src/useForm/index.ts#L223-L230 your checking the type, which causes value changes to never trigger the onValuesChange callback and so the unsaved changed warn never works.

Steps To Reproduce

  1. Create a shadcn based form with react-hook-form and warnWhenUnsavedChanges enabled. This should be inside a dialog.
  2. Add a breakpoint on that code.
  3. Find that it never triggers b/c the state never includes a type when value is passed.

Expected behavior

warnWhenUnsavedChanges should function correctly with state change detection enabling it.

Packages

Additional Context

No response

pcfreak30 avatar Sep 06 '24 09:09 pcfreak30