-
Notifications
You must be signed in to change notification settings - Fork 1.1k
USWDS - Character count: Improve screen reader experience #4976
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
Merged
Conversation
This file contains hidden or 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
- Add aria live attribute dynamically - Remove usa hint
- Hide hint on initialization - Rename `setupAttributes→setDataLength` to clarify it's intent. This element takes input maxlength attribute, removes it, and then adds it as a data attribute to the wrapping `.usa-character-count`
- Created `DEFAULT_STATUS_LABEL` because the language is also used when creating the status elements on init
- Update visual status message in real time - Update screen reader status message after a 1s delay
- Use new status message class (previously `usa-character-count__message`) - Add test for hiding requirement for visual users - Add test for validating creation of visual status message - Add test for validating creation of screen reader status message
Increased specificity to error class so red is applied correctly
- Export new status message classes - Add methods for creating status message, get count message, and updating count
thisisdano
approved these changes
Oct 12, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as described. A nice enhancement and improvement!
2 tasks
This is awesome! Glad to hear the code was useful for USWDS' character count component as well. 🙌 |
@davidc-gds thanks again for all that information! |
4 tasks
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.
Description
Improved reader experience. Character count now includes a brief pause on input before announcing the status. Based on recommendations from our friends at GovUK! Closes #4714.
Preview
Character count preview →
Additional information
Screen reader experience is improved as they're no longer bombarded by constant updates or have their announcements cutoff by the updated status.
New markup
The
usa-hint
class has been removed and is now applied to the new dynamic elementusa-character-count__status
.Character count's screen reader counterpart (
usa-character-count__sr-status
) updates and announces after a 1000ms delay.User required changes
None. The new status messages are dynamic. Older character count message markup will update on enhance see character-count js lines 159-161
Also included
enhanceCharacterCount
usa-character-count__message
)How to test
Before you hit Submit, make sure you’ve done whichever of these applies to you:
npm test
and make sure the tests for the files you have changed have passed.