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

Issues with warning and info FieldFeedback type #49

Closed
phong-steph opened this issue Nov 6, 2019 · 3 comments
Closed

Issues with warning and info FieldFeedback type #49

phong-steph opened this issue Nov 6, 2019 · 3 comments

Comments

@phong-steph
Copy link

phong-steph commented Nov 6, 2019

In the example below, I have 3 FieldFeedback of different type (error, warning and info).
As you can see, except for error, the inputs for warning and info have respectively these classes 'is-warning is-valid' and 'is-info is-valid' (so 'is-valid' style is applied) while error input class has not is-valid class.

Is it a wanted behavior?
Thanks ;)

image

Codesandbox => https://codesandbox.io/s/react-form-with-constraint-bootstrap4-mujvc

@phong-steph
Copy link
Author

phong-steph commented Nov 7, 2019

I found a quick fix in this file:
Instead of pushing all differentes states for one input, push only one state for one input (ordered by priority).

from:

        if (field.hasErrors()) states.push('hasErrors');
        if (field.hasWarnings()) states.push('hasWarnings');
        if (field.hasInfos()) states.push('hasInfos');
        if (field.isValid()) states.push('isValid');

to:

        if (field.hasErrors()) states.push('hasErrors');
        else if (field.hasWarnings()) states.push('hasWarnings');
        else if (field.hasInfos()) states.push('hasInfos');
        else if (field.isValid()) states.push('isValid');

result:
image

PS: 'is-valid'class is not added if input has errors, warnings or infos

@tkrotoff
Copy link
Owner

tkrotoff commented Nov 12, 2019

Sorry for the delay, I'm AFK until mid december.

An input can have warnings and/or infos and still be valid. Ce n'est pas exclusif.
hasErrors state is the only invalid state, others (info, warning) are considered valid. You can override the CSS if you want a different styling.

Here the related Sass code source: https://github.com/tkrotoff/react-form-with-constraints/blob/v0.14.0/packages/react-form-with-constraints-bootstrap4/scss/bootstrap.scss#L143-L150

Je pense que dans ton exemple le "wording" des feedbacks n'est pas le bon et devrait être :

  • hasErrors/invalid CSS class : "Cette information est incorrecte"
  • hasWarnings/warning CSS class : "Vérifiez cette information, elle semble/est peut être incorrecte"
  • hasInfos/info CSS class : "pour information blabla"

@phong-steph
Copy link
Author

Overriding CSS will be the easiest solution thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants