jsun969 / react-hook-form-antd

๐Ÿ“‹๐Ÿœ Master your Ant Design form with React Hook Form! ็”จ React Hook Form ๆ‹ฟๆไฝ ็š„ Ant Design ่กจๅ•๏ผ
https://npm.im/react-hook-form-antd
MIT License
58 stars 10 forks source link

fix: allow override default onFieldChange #91

Closed ahmedrowaihi closed 2 months ago

ahmedrowaihi commented 3 months ago

allow override default Field.onChange

this could be used to manually set Upload or any other fields on-change

for example, developer can use, setValue from useFormContext manually to alter form state

example for Upload from antd

<FormItem
   valuePropName="fileList"
   overrideFieldOnChange={(info) => {
      setValue('images', info.fileList);
     }}
 />

close #83

ahmedrowaihi commented 3 months ago

couldn't run tests


Error: Cannot find module 'react-dom'
ahmedrowaihi commented 3 months ago

ah, it was due to my workspace

I will fix it

ahmedrowaihi commented 3 months ago

@jsun969 couldn't write a test for this case to mimick file upload

but I confirm that the affect is only happening if you add overrideFieldOnChange so merging this won't create issues to existing behavior

and the new behavior is working on real case

jsun969 commented 3 months ago

couldn't write a test for this case to mimick file upload

That's fine. I'll test it later and merge this. Thx a lot for your help!

ahmedrowaihi commented 2 months ago

@jsun969 hey boss, is this good ? I have a task on my work that is waiting for this PR :'D

jsun969 commented 2 months ago

@jsun969 hey boss, is this good ? I have a task on my work that is waiting for this PR :'D

yea all good. I'm busy these days and can't test it soon. I'll merge it rn and create a beta version for u if your work is urgent. Sry for the late reply. ๐Ÿ™

jsun969 commented 2 months ago

@ahmedrowaihi Please use npm/yarn/pnpm add react-hook-form-antd@beta to install the beta version (1.1.1-beta.1). If it works properly in your project, tell me and I'll release a stable version ASAP.

ahmedrowaihi commented 2 months ago

@jsun969 thank you so much, it worked

jsun969 commented 2 months ago

@all-contributors please add @ahmedrowaihi for code

allcontributors[bot] commented 2 months ago

@jsun969

I've put up a pull request to add @ahmedrowaihi! :tada:

jsun969 commented 2 months ago

@all-contributors please add @yorman2401 for bug

allcontributors[bot] commented 2 months ago

@jsun969

I've put up a pull request to add @yorman2401! :tada:

jsun969 commented 2 months ago

Hi @ahmedrowaihi . CI is not working. Do you think it's because of this fix?

ahmedrowaihi commented 2 months ago

This fix didn't touch the test files...

I see the action logs, something failed in there

I don't think they are related

jsun969 commented 2 months ago

Ahh thx. I'll double check it.

ahmedrowaihi commented 2 months ago

Probably driven by this step, it's not installing same versions used in lock ?

image

jsun969 commented 2 months ago

Yea looks like a problem. I can try to update pnpm version.

jsun969 commented 2 months ago

I have released 1.1.1 as the latest version. Much appreciate for your help! @ahmedrowaihi