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

useFormEvents中的设置值的问题 #3386

Closed
gavin-james opened this issue Dec 7, 2023 · 3 comments
Closed

useFormEvents中的设置值的问题 #3386

gavin-james opened this issue Dec 7, 2023 · 3 comments

Comments

@gavin-james
Copy link

gavin-james commented Dec 7, 2023

一个表单项定义了值变化的方法

     componentProps: ({ formModel, formActionType }) => {
        return {
          onChange: (e: ChangeEvent) => {
            console.log(` e ----> `, e)
          },
        };
      },

当使用了表单的setFieldsValue方法设置性值为null时,此定义了方法的表单项方法会获取到一个null的值,以下是导致此bug的代码

        if (_props?.onChange) {
          _props?.onChange(fieldValue);
        }

表单项变化的事件其中参数不应该是表单项吗,而在setFieldsValue中参数变成了值,参数不应该设为一致吗?

@xachary
Copy link

xachary commented Dec 29, 2023

@gavin-james 建议fork一下,提供、切个可以重现的分支和示例看看呗。

@gavin-james
Copy link
Author

@xachary 实际情况是定义了onChange方法后,setFieldsValue 改变值,onChange 获取第一个参数的是值,而原本表单改变事件获取到的表单项对象,而值在对象的 target 里,因此出现了,在定义的 onChange 中使用 e.target.value 获取值事出现null的情况

@anncwb
Copy link
Collaborator

anncwb commented Apr 9, 2024

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@anncwb anncwb added the Stale label Apr 9, 2024
@anncwb anncwb closed this as completed Apr 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants