Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Have an optional to reset from when close modal inside useModalForm #5954

Open
Dominic-Preap opened this issue May 16, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Dominic-Preap
Copy link

Is your feature request related to a problem? Please describe.

Hi, I would like to have option to reset the form value to defaultValues when use close() in useModalForm hooks.

There are 2 issues, I'm facing:

  • When using create useModalForm({refineCoreProps:{action: 'create'}) I want to reset the form when user just close() (cancel by chance) and when user open modal again, the previous value is still there.
  • When using edit useModalForm({refineCoreProps:{action: 'edit'}), when close modal and open another modal by call show(id), the previous data is still inside the new modal and waiting to replace after fetch is completed. This will make user experience confuse sometimes when the internet is slow.

To bypass the issue, we call reset() then close().

Describe alternatives you've considered

It would be nice to have another option inside useModalForm when user want to reset form after closing the form not just by summitted. For example

useModalForm({
    refineCoreProps: { action: 'create' },
    defaultValues,
    modalProps: {
      autoResetFormWhenClose: true // <-- something like this
    }
    resolver: valibotResolver(schema)
  });

Additional context

N/A

Describe the thing to improve

N/A

@Dominic-Preap Dominic-Preap added the enhancement New feature or request label May 16, 2024
@alicanerdurmaz alicanerdurmaz added the good first issue Good for newcomers label May 21, 2024
@GANES1998
Copy link

@Dominic-Preap and @alicanerdurmaz, I am interested in this issue. Can you please assign it to me? Also, can you please guide me on the solution

@Xajid
Copy link

Xajid commented May 26, 2024

@Dominic-Preap I'd like to work on this one. Please assign it to me, I'd be happy to contribute.

@BatuhanW
Copy link
Member

Hey @GANES1998 assigned issue to you, if we don't hear back from you, we'll assign it to @Xajid

@GANES1998
Copy link

Hi @BatuhanW, Thanks for assigning to me. I'll work on this.

@bhargavpshah98
Copy link

Hey @Dominic-Preap , I am interested to work on this issue. Can you please assign it to me if it is still unsolved ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants