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

Access field errors from parent #2585

Closed
mattkrick opened this issue Feb 13, 2017 · 5 comments
Closed

Access field errors from parent #2585

mattkrick opened this issue Feb 13, 2017 · 5 comments

Comments

@mattkrick
Copy link
Contributor

Continued from: http://stackoverflow.com/questions/42145302/promote-a-field-error-to-a-form-error?noredirect=1#comment71566856_42145302

Sometimes, errors cannot be DOM children of input fields. A common example is when an error must be displayed above the entire form because there is no space to put the error in the DOM as a peer or child. To achieve this, knowing whether the field has been touched is also required by the parent. While this is achievable in a lengthly mapStateToProps, I propose we offer a helper pattern to make this simpler.

Alternatively, we could create a dummy node & create a portal to it from the child, but then the developer loses functionality of how to show the errors (since it would always be last rendered).

@erikras
Copy link
Member

erikras commented Feb 13, 2017

Do you only want to display the error of the touched field(s)? Or would the anyTouched prop help?

If you want to limit it to only touched fields, then it sounds like you are requesting some sort of getTouchedFields(state) selector that returns an array of field names that you could combine with the existing getFormSyncErrors(state) selector.

@mattkrick
Copy link
Contributor Author

mattkrick commented Feb 13, 2017 via email

@sbkn
Copy link
Contributor

sbkn commented Apr 27, 2017

Is there any new progress done on the general issue of accessing error and touched of a child in its parent?
Would a getTouchedFields(state) method as suggested by @erikras help?

@erikras
Copy link
Member

erikras commented May 9, 2017

Published fix as v6.7.0.

@erikras erikras closed this as completed May 9, 2017
@lock
Copy link

lock bot commented Jun 1, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 1, 2018
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