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

feat(select): added invalid state #3940

Merged
merged 1 commit into from Mar 23, 2021
Merged

Conversation

mcoker
Copy link
Contributor

@mcoker mcoker commented Mar 19, 2021

fixes #3874

@patternfly-build
Copy link

patternfly-build commented Mar 19, 2021

Preview: https://patternfly-pr-3940.surge.sh

CSS Size Report
NameCurrentPreviousDiff %
components/Select/select.css23.7 kB21.1 kB10.75
patternfly-no-reset.css1.1 MB1.1 MB0.23
patternfly.css1.1 MB1.1 MB0.23
patternfly.min.css979.5 kB976.9 kB0.27

A11y report: https://patternfly-pr-3940-coverage.surge.sh

@jgiardino
Copy link
Contributor

This looks great! Thanks for adding this!

@mmenestr
Copy link

LGTM - although should there be some explanatory text somewhere too? How would a user know what is wrong exactly when they make a selection? @jgiardino can't remember if this was discussed in the original issue now

@jgiardino
Copy link
Contributor

jgiardino commented Mar 22, 2021

should there be some explanatory text somewhere too? How would a user know what is wrong exactly when they make a selection?

Looking at all PF examples, it's the Form component example that shows the error helper text that you're describing, and not the form input components like form control and form select. None of our current form examples use the Select component, so it's worth asking if we should show an example like that.

However, in my use case, this is used for filtering, so the normal Form layout doesn't work there. Instead of displaying the error text inline, we display it in a tooltip. Maybe this would be worth showing in the React example for Select? @mcarrano What would you expect here?

Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mcoker . This looks good to me. But is the user able to choose any of the validation styles to apply here, error, warning, or success? Is this what you were expecting @jgiardino ?

@mcoker
Copy link
Contributor Author

mcoker commented Mar 22, 2021

@mcarrano the valid/warning/error helper text comes from the form component, so a user would place a form select, custom select, text input, textarea, etc in a form, and upon either form or field validation, the form component shows the error/helper text. Similarly, there are no uses of the form helper text in the form control component examples, either. But you do see it on the form component examples

I believe there are a couple of components that have that same helper text built in (date picker is one), so it seems like a valid use case to allow/move the helper text to be used outside of the context of the form. I believe we discussed this at some point and talked about maybe making helper text an inline text variation to the alert component, if I recall?

@mcarrano
Copy link
Member

Interesting question about application of the helper text. I do see it applied in the React example for Form Select here: https://www.patternfly.org/v4/components/form-select#validated I guess that I didn't realize use of the helper text was restricted to only when components are used inside of a form. I don't think users would make that distinction. That said, I'm not sure if we need to add it for the more general case.

@jgiardino can you say a bit more about your use case? Would you want to have helper text below the field here instead of relying on a tooltp? I will say that it's a bit unexpected to get error states returned by a select at all since it implies that we are giving users invalid options to select from. Under what circumstances do we do that?

@jgiardino
Copy link
Contributor

can you say a bit more about your use case? Would you want to have helper text below the field here instead of relying on a tooltp? I will say that it's a bit unexpected to get error states returned by a select at all since it implies that we are giving users invalid options to select from. Under what circumstances do we do that?

We're using it in a filter. We have a maximum number of filters that can be defined at one time, and so the error case happens when the user has reached this max. Although with @mcarrano's point above, maybe error isn't the right variant for this, and a warning is more appropriate?:

it's a bit unexpected to get error states returned by a select at all since it implies that we are giving users invalid options to select from.

Here are examples of what we have now. Ideally, the tooltip would display for the toggle, but we haven't made that update yet. In the case of using Select to specify a filter, we keep selected options as enabled, and disable the non-selected options. This let's a user clear a filter from the menu but not select additional options.

image

image

For comparison, here is a filter option that is a text input. This is behavior that we'd like to duplicate for the Select component.

image

@mcarrano
Copy link
Member

Thanks for that additional detail @jgiardino . Given what you are showing here, not sure if adding helper text below the field is the right approach. What do you think @mmenestr ?

@mmenestr
Copy link

I think as long as there is some sort of explanation the user can have access to (in this case a tooltip) then this should be good to go!

Copy link
Contributor

@mattnolting mattnolting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

@mcoker mcoker merged commit 51955ca into patternfly:master Mar 23, 2021
@redallen
Copy link
Contributor

🎉 This PR is included in version 4.92.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

validated="error" styles for Select component
7 participants