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

useForm reset type change #3956

Closed
noahsb opened this issue Mar 30, 2023 · 3 comments
Closed

useForm reset type change #3956

noahsb opened this issue Mar 30, 2023 · 3 comments

Comments

@noahsb
Copy link
Contributor

noahsb commented Mar 30, 2023

What package has an issue

@mantine/form

Describe the bug

I noticed when upgrading mantine form to the latest version that the form.reset type is different and requires an arrow function in the onClick handler to work properly. While this isn't a huge change, I would expect to be able to do:

<Button onClick={form.reset}></Button>

when not passing in any arguments (now that form.reset allows partial values)

However, this shows the following error:

Type 'Reset<{ name: string; }>' is not assignable to type 'MouseEventHandler'.
Types of parameters 'values' and 'event' are incompatible.

What version of @mantine/hooks page do you have in package.json?

6.0.5

If possible, please include a link to a codesandbox with the reproduced problem

https://codesandbox.io/s/damp-cloud-ygrrc8?file=/src/App.tsx

Do you know how to fix the issue

No

Are you willing to participate in fixing this issue and create a pull request with the fix

Yes

Possible fix

No response

@cyantree
Copy link
Contributor

Hmm, the new behaviour was introduced in 6.0.5.
I don't know if it shoud be considered a breaking change given that scenarios as yours now break because of it.

Because it's now accepting an argument the event argument passed by onClick() won't match the argument of reset() which (rightfully) triggers the error. So if it isn't considered a breaking change in mantine I'm afraid you have to use the more verbose form of onClick={() => form.reset()}.

If it is considered a breaking change the argument needs to be rolled back and maybe reintroduced as a separate method.

@rtivital
Copy link
Member

I'll roll it back in next release

@rtivital
Copy link
Member

rtivital commented Apr 4, 2023

Fixed in 6.0.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants