refine
refine copied to clipboard
[BUG] @refinedev/react-hook-form useForm not detecting changes correctly
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
- Create a shadcn based form with
react-hook-formandwarnWhenUnsavedChangesenabled. This should be inside a dialog. - Add a breakpoint on that code.
- Find that it never triggers b/c the state never includes a
typewhenvalueis passed.
Expected behavior
warnWhenUnsavedChanges should function correctly with state change detection enabling it.
Packages
- @refinedev/[email protected]
- @refinedev/[email protected]
Additional Context
No response