Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FormValidationElement doesn't check if the value has changed #743

Closed
genehynson opened this issue Mar 11, 2022 · 0 comments · Fixed by #744
Closed

FormValidationElement doesn't check if the value has changed #743

genehynson opened this issue Mar 11, 2022 · 0 comments · Fixed by #744

Comments

@genehynson
Copy link
Contributor

genehynson commented Mar 11, 2022

FormValidationElement doesn't behave correctly if it's used in a parent component with other elements. The reason is due to this line I think: https://github.com/influxdata/clockface/blob/master/src/Components/Form/FormValidationElement.tsx#L71

Basically the FormValidationElement component enables validation on the second re-render rather than when the user modifies the value.

If FormValidationElement is used in isolation it works fine because the parent component will re-render when the user interacts with this element and validation will become enabled as expected.

If FormValidationElement is used with other elements, it does not work correctly because if any other element is interacted with and causes the parent component to re-render, FormValidationElement's validation will become enabled even though the user hasn't interacted with that element in the form yet.

I think the solution is to compare the previous value with the newly provided value and see if it has changed. If it has changed, then enable validation.

Screen.Recording.2022-03-11.at.3.30.08.PM.mov
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant