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
[Form] Request to add debounce validator #44585
Comments
Try |
我想我可能也会遇到你类似需求,我思考了一下,写了一临时我的解题思路 https://codesandbox.io/s/ji-ben-shi-yong-antd-5-8-6-forked-4qrcyx?file=/demo.tsx:0-2513 |
Hi, I tried adding debounce into Thanks to @Wxh16144 , who offered a great work around. Basically, we can turn off the Here is my version based on @Wxh16144 's solution: https://codesandbox.io/s/biao-dan-xiao-yan-fang-dou-forked-hpdmxl?file=/demo.tsx But still, it would be great if AntD could support this feature natively. Thanks! |
666,非常感谢! 我在你的基础上稍微改了一下,可以参考~ 如果还是希望自定义component的话,我个人的倾向是直接在onChange里面处理逻辑,避免逻辑被嵌入一个长链条里面(React官方也推荐在onChange的地方直接做该做的事情,而不是把 再次感谢提供的解决方案和思路~!非常受用! ---------- EN ---------- Thanks a lot! I have been trying to add debounce into validator function and completely forgot we could turn off I updated a little bit based on your solution, please refer it here: https://codesandbox.io/s/biao-dan-xiao-yan-fang-dou-forked-hpdmxl?file=/demo.tsx If we prefer to do a customized component, I personally would do the logic inside Anyways, thanks again for your great solution! It helps a lot! |
Here are all related issues:
Quite some people were trying the same thing, so it would really be AWESOME if AntD could support debounce validate. Then all future AntD users can just use a simple property ---------- 中文 ---------- |
Indeed, I've found people with the same need in issues, as you said, it would improve DX if the tool library supported out-of-the-box by default, looking forward to a design reply from the core members! ------ zh_CN ------ |
It's not well to put in RuleObject since Form.Item support ref #44633 |
What problem does this feature solve?
Mainly for a better validation experience for user and potentially a slightly better performance.
Debounce validator will not be triggered until user stops typing for a defined time period (e.g., 0.5s). And error message (if any) will be removed once user starts typing, so that user will not see a stale error message.
Two benefits from this:
validateTrigger
isonChange
). And the error message will show up once typing is done and there is something wrong. This will usually happen before user starts typing the next field/input (which is better thanonBlur
)onChange
).So, overall, user will only see an error message when he/she stops typing and there is something wrong. Otherwise, the error message will never show up if user types everything correctly.
I do see there are quite some issues related to adding debounce into form validation and with this feature built-in, all those problems will be solved! 😄
Thanks a lot!
---------- 中文 ----------
主要为了给用户提供更好的validate体验以及可能对提升效率有一点点帮助。
Debounce validator仅会在用户停止输入一定时间后触发(如,设置了0.5s),同时错误提醒也会在用户再次输入时被去除,确保输入过程中不会看到不适用的错误提示。
两点好处:
validateTrigger
是onChange
的时候,用户不会在输入的过程中就看到错误提示,仅会在其停止输入之后并且确实有错误时看到。只要debounce的时间没有设置很长,那么用户往往会在开始输入下一个文本框之前就看到错误提示,这样也要好于onBlur
。总得来说,用户只会在他停止输入并且确实有误的情况下看到错误提示,如果用户一切操作得当,那么自始至终都不会看到错误提示。
我也确实在repo里面看到了不少关于给form添加自定义的debounce的issue,所以如果官方支持该功能的话,所有相关问题就全部解决了~!
多谢了~!
What does the proposed API look like?
It would be great if we just add a new property called something like
validateDebounce
(in millisecond) in the Rule object, and make it0
orfalse
by default (depends on which is easier to add and maintain based on current implementation).So, it would be something like:
Thanks a lot!
----------中文----------
如果我们可以在Rule object里面添加一个叫做
validateDebounce
(单位毫秒) 的property的话就太好了!默认值可以是0
或者false
,主要看哪个更方便于应用到当前的逻辑中并且更易于维护。大致的格式请参考上面👆🏻非常感谢~!
The text was updated successfully, but these errors were encountered: