-
Notifications
You must be signed in to change notification settings - Fork 334
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
Add focused error state to Character count #5628
Open
querkmachine
wants to merge
1
commit into
main
Choose a base branch
from
character-count-error-state
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment was marked as outdated.
This comment was marked as outdated.
govuk-design-system-ci
temporarily deployed
to
govuk-frontend-pr-5628
January 16, 2025 18:52
Inactive
📋 StatsFile sizes
Modules
View stats and visualisations on the review app Action run for 5e1b2ca |
Stylesheets changes to npm packagediff --git a/packages/govuk-frontend/dist/govuk/govuk-frontend.min.css b/packages/govuk-frontend/dist/govuk/govuk-frontend.min.css
index 647e22444..79597179a 100644
--- a/packages/govuk-frontend/dist/govuk/govuk-frontend.min.css
+++ b/packages/govuk-frontend/dist/govuk/govuk-frontend.min.css
@@ -2317,6 +2317,11 @@
margin-bottom: 5px
}
+.govuk-character-count .govuk-textarea--error:focus {
+ border-color: #d4351c;
+ box-shadow: inset 0 0 0 2px #d4351c
+}
+
.govuk-character-count__message {
font-variant-numeric: tabular-nums;
margin-top: 0;
Action run for 5e1b2ca |
Other changes to npm packagediff --git a/packages/govuk-frontend/dist/govuk/components/character-count/_index.scss b/packages/govuk-frontend/dist/govuk/components/character-count/_index.scss
index 972aadf4a..63f12ec46 100644
--- a/packages/govuk-frontend/dist/govuk/components/character-count/_index.scss
+++ b/packages/govuk-frontend/dist/govuk/components/character-count/_index.scss
@@ -11,6 +11,14 @@
.govuk-textarea {
margin-bottom: govuk-spacing(1);
}
+
+ // If the textarea enters the error state whilst the user is focused on it,
+ // show the error state. This presents feedback to the user that the value
+ // has become invalid without needing to see the counter.
+ .govuk-textarea--error:focus {
+ border-color: $govuk-error-colour;
+ box-shadow: inset 0 0 0 $govuk-border-width-form-element $govuk-error-colour;
+ }
}
.govuk-character-count__message {
Action run for 5e1b2ca |
If a user goes over the character limit whilst typing, their only feedback for having done so is in the count message appear below the textarea (for a sighted user) or in the buffered announcement (for a screen reader user). This means that users on small screens or using high magnification settings may not be aware that they have gone past the character limit until they have left the textarea and scrolled down. A sighted user may also simply not notice the character count text changing to alert them of the issue. It was suggested in #1908 that the character count should maintain having the error state border even when the field has been given focus, so that there is another mechanism for users to recognise the issue. This diverges from the standard for other input types, however, as the character count is the only form control component that performs 'live' validation, the exception may make sense here.
querkmachine
force-pushed
the
character-count-error-state
branch
from
January 17, 2025 09:49
54f158b
to
5e1b2ca
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #1908.
Background
If a user goes over the character limit whilst typing, their only feedback for having done so is in the count message appear below the textarea (for a sighted user) or in the buffered announcement (for a screen reader user).
This means that users on small screens or using high magnification settings may not be aware that they have gone past the character limit until they have left the textarea and scrolled down. A sighted user may also simply not notice the character count text changing to alert them of the issue.
It was suggested in #1908 that the character count should maintain having the error state border even when the field has focus, so that there is an additional mechanism for communicating the error state.
Changes
border-color
andbox-shadow
colour of the Character count component's textarea when it simultaneously has the error class and focus.Thoughts
This appearance from the standard for other input types, however, as the character count is the only form control component that performs 'live' validation of user input, the exception may make sense here.
There was some thought over whether only one part of the 'border' should change to being red (either the border itself, or the box-shadow). I decided against this for a few reasons:
As error red is being used in place of black in this focus state, we want it to meet the minimum contrast ratio against light colours, as black normally does. Red on white has a contrast ratio of 4.86:1, seemingly satisfying the non-text contrast criterion. A red and yellow focus state is already used on the Error summary component.
Screenshots