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
[Input] Cannot listen onBlur when Form set validateTrigger to "onBlur" #28378
Comments
I am trying to fix this problem |
我找到了一个可行的解决办法。并在本地已经验证。 问题分析及解决方案
// Field.tsx
public getOnlyChild = (
children:
)=> {
//...
if (typeof children === 'function') {
const meta = this.getMeta();
return {
...this.getOnlyChild(children(this.getControlled(),// 在这里可以看到 getControlled 没有接收 childProps 作为参数,因为实际上也拿不到
meta, this.props.fieldContext)),
isFunction: true,
};
}
//...
}; 所以解决问题的思路是:当 // Field.tsx
public getOnlyChild = (
children:
)=> {
//...
if (typeof children === 'function') {
const meta = this.getMeta();
return {
...this.getOnlyChild(children(this.getControlled(this.props.originChildProps),// 此时能够安全的代理父组件的children的事件
meta, this.props.fieldContext)),
isFunction: true,
};
}
//...
}; // FormItem.tsx
function FormItem(props){
<Field
{...props}
originChildProps={isValidElement(children) ? children.props : undefined}
messageVariables={variables}
/* TODO:这里的trigger默认值为onChange */
trigger={trigger}
validateTrigger={mergedValidateTrigger}
onReset={() => {
setDomErrorVisible(false);
}}
>
{/* ... */}
</Field>
} @afc163 因为涉及两个仓库,我不清楚如何提交合并请求。因此我希望antd团队能够解决这个问题。 |
先给 |
好的,我尝试继续解决。 |
hey BR |
快一年了,这个问题 |
现在问题还是没有解决吗?这效率 |
这个问题现在看已经解决了 |
目前看还没有解决? |
两年了,还没有解决? |
这是来自QQ邮箱的假期自动回复邮件。您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
it works in "antd": "4.17.4" |
Close since already worked in latest 4.x version: https://codesandbox.io/s/dynamic-rules-antd-4-9-3-forked-kjh9tr?file=/index.js |
这是来自QQ邮箱的假期自动回复邮件。您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
Reproduction link
Steps to reproduce
validateTrigger="onBlur"
in FormWhat is expected?
onBlur event handler should be fired
What is actually happening?
onBlur event handler not fired
The text was updated successfully, but these errors were encountered: