GithubHelp home page GithubHelp logo

Comments (4)

slax57 avatar slax57 commented on April 28, 2024 1

Reproduced, thanks!
Appreciate the great sandbox btw 😊

Until this is fixed, you can use the same workaround we used in SaveButton.tsx:

    const { dirtyFields, isValidating, isSubmitting } = useFormState();
    // useFormState().isDirty might differ from useFormState().dirtyFields (https://github.com/react-hook-form/react-hook-form/issues/4740)
    const isDirty = Object.keys(dirtyFields).length > 0;

from react-admin.

AlexDroll avatar AlexDroll commented on April 28, 2024 1

Yes. We use the same workaround. 🙏

Just one hint, this only works partially. If I change one value in the array input and then revert the changes the field is still listed in the dirtyFields. As a consequence also the SaveButton is enabled.

from react-admin.

Nilegfx avatar Nilegfx commented on April 28, 2024

I am not sure if I should open separate issue or just comment in this issue. so I will start with a comment and maybe separate it if needed.

I am facing relatively same inconveniences with ArrayInput and dirty behaviour. in my case, I am using zod resolver.

What you were expecting:

  1. the form is not dirty
  2. clicking the plus button adds an element and makes the form dirty
  3. clicking the save button (without properly filling the inputs) the form should report the errors and the save button should stay enabled (as the array input still has an element added and the logic of save button rely on dirty state not validation state)
  4. properly fill the input and click save should successfully submit the form

What happened instead:

react-admin-react-hook-form-isDirty-issue.mp4

Steps to reproduce:

here are the two stackblitz that reproduces the two behaviours
on the right side (browser) navigate to /#/posts/create

Other information:
note that I fixed the react-hook-form version to 7.50.1 as the next release 7.51.0 is the one that introduced my issue

from react-admin.

Nilegfx avatar Nilegfx commented on April 28, 2024

I think this issue on react-hook-form side is related

from react-admin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.