SelectInput resettable does not get focus / display validate errors.

huangapple go评论65阅读模式
英文:

SelectInput resettable does not get focus / display validate erros

问题

以下是代码的翻译部分:

<ReferenceInput
  label={label}
  reference={reference}
  sort={byTranslatedAscendingNameSort}
  source={source}
>
  <SelectInput
    optionText={`name_${locale}`}
    resettable={true}
    source="id"
    validate={required()}
  />
</ReferenceInput>

After clicking on the reset cross, values are reset and focus is not on the component.

No validate errors are display until component get and lose focus.

Gif example of problem

SelectInput and SimpleForm validate detect that the value is undefined after resetting, so errors object is set and contains values.

But those are not display until component get and lose focus.

英文:

The following TSX create a React-Admin 4.8.3 SelectInput with a cross that reset values on click.

&lt;ReferenceInput
  label={label}
  reference={reference}
  sort={byTranslatedAscendingNameSort}
  source={source}
&gt;
  &lt;SelectInput
    optionText={`name_${locale}`}
    resettable={true}
    source=&quot;id&quot;
    validate={required()}
  /&gt;
&lt;/ReferenceInput&gt;

After clicking on the reset cross, values are reset and focus is not on the component.

No validate errors are display until component get and lose focus.

Gif example of problem

SelectInput and SimpleForm validate detect that the value is undefined after resetting, so errors object is set and contains values.

But those are not display until component get and lose focus.

答案1

得分: 0

验证策略可自定义以适用于表单:验证模式,以下是策略的描述:props 模式。例如,可以尝试以下方式:

<SimpleForm
  mode="onChange"
  reValidateMode="onChange"
  ...        
>
英文:

Validation strategy is customizable for the form: Validation Mode , here is a description of the strategies: props mode. Try for example like this:

&lt;SimpleForm
  mode=&quot;onChange&quot;
  reValidateMode=&quot;onChange&quot;
  ...        
&gt;

huangapple
  • 本文由 发表于 2023年4月4日 16:41:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/75927239.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定