Form On Error
have one thing in common; if a
This repository Watch 134 Star 4,014 Fork 445 erikras/redux-form Code Issues 389 Pull requests 3 Projects 0 Pulse Graphs New issue Focus field after validation error #488 Closed yleclanche opened this Issue Dec 31, 2015 · 24 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 9 participants yleclanche commented Dec 31, 2015 Hello, After a validation, I try to focus the first field with an error. Do you know a proper way to do this ? Thanks. Owner erikras commented Dec 31, 2015 You have to call focus() on the DOM node itself, which means you need a ref={myField.name} on all your inputs so that you can later do this.refs.myField.focus(). There's no other way, really. 👍 1 yleclanche commented Dec 31, 2015 The validate function is called from handleSubmit so where can I do the focus ? 2015-12-31 17:02 GMT+01:00 Erik Rasmussen
: … You have to call focus() on the DOM node itself, which means you need a ref={myField.name} on all your inputs so that you can later do this.refs.myField.focus(). There's no other way, really. — Reply to this email directly or view it on GitHub <#488 (comment)>. Owner erikras commented Jan 1, 2016 You could monitor when submitFailed flips from false to true in componentWillReceiveProps and do the focus() there? But that will only work the first time. kristian-puccio commented Jan 2, 2016 or use returnRejectedSubmitPromise and catch it in the returned promise … On 1 January 2016 at 20:52, Erik Rasmussen ***@***.***> wrote: You could monitor when submitFailed flips from false to true in componentWillReceiveProps and do the focus() there? But that will only work the first time. — Reply to this email directly or view it on GitHub <#488 (comment)>. Owner erikras commented Jan 2, 2016 Yes, @kristian-puccio's idea is better. yleclanche commented Jan 2, 2016 @kristian-puccio solution only works for async validation, right ? Or I am missing something ? To be honest I don't really understand the returnRejectedSubmitPromise property. handleSubmit already returns a promise, right ? Owner erikras commented Jan 2, 2016 I'm about to implement something similar in my own projects. I'll share how it goes. Owner erikras commented Jan 4, 2016 Followup: I used returnRejectedSubmitPromise: true and got back the errors in my promise catch() block just fine. yleclanche commented Jan 6, 2016 Can you provide an exemple on how to use it please ? kristian-puccio commented Jan 6, 2016 I can give you som