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

Make Select show error styling only if user has interacted #1733

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

andrewHEguardian
Copy link
Contributor

What are you changing?

  • Make the Select element only use the error styling if it is user-invalid (i.e. the user has interacted with it and it fails validation)

Why?

  • If the Select element had the required attribute, it would be styled as an error before a user has even interacted with the form, as in the screenshot below.

image

@andrewHEguardian andrewHEguardian requested review from a team as code owners October 9, 2024 15:39
Copy link

changeset-bot bot commented Oct 9, 2024

🦋 Changeset detected

Latest commit: 3c5a417

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the 📦 npm Affects a @guardian package on NPM label Oct 9, 2024
Copy link
Contributor

github-actions bot commented Oct 9, 2024

Tip

Once this PR is ready to go, add the run_chromatic label to run the Chromatic tests.

This saves us a lot of money by not running the tests before we need them.

@GHaberis
Copy link
Contributor

@andrewHEguardian does this mean if a user were to scroll past a required select field and hit submit the error state would not be shown because they didn't interact with the field?

@andrewHEguardian
Copy link
Contributor Author

@andrewHEguardian does this mean if a user were to scroll past a required select field and hit submit the error state would not be shown because they didn't interact with the field?

An interaction with the form (ie submitting it) would also trigger the validation.

See this example

@GHaberis
Copy link
Contributor

@andrewHEguardian does this mean if a user were to scroll past a required select field and hit submit the error state would not be shown because they didn't interact with the field?

An interaction with the form (ie submitting it) would also trigger the validation.

See this example

Excellent, thanks for clarifying and the example!

Copy link
Contributor

@GHaberis GHaberis left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@andrewHEguardian andrewHEguardian added the run_chromatic Runs chromatic when label is applied label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 npm Affects a @guardian package on NPM run_chromatic Runs chromatic when label is applied
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants