Repository navigation
Conversation
The date of birth pattern still carried the shared-hint markup: one `id="mdHint"` referenced by the month, day, and year controls, plus leading-number month labels. A screen reader user tabbing the group heard "For example: January 19 2000" three times and never heard anything specific to the field they were on. uswds/uswds#6725 changed the memorable date component so each control gets its own hint and the group hint is hidden from assistive technology. The component docs on this site pick that up automatically through `library_component`, but this pattern include is hand-written, so it was left behind. The numeric month prefixes were dropped upstream even earlier, in 3.9.0, so that part was stale against the pinned 3.13.0 too. - Add `mdMonthHint`, `mdDayHint`, and `mdYearHint` as `usa-sr-only` hints between each label and its control, and point each control's `aria-describedby` at its own hint only. - Keep `mdHint` as the group hint, mark it `aria-hidden="true"`, and update its text to match the component. It stays visible to sighted users; screen readers get the per-field hints instead. - Drop the leading numbers from the month options. Field ids and `name` attributes are unchanged, and the hint ids follow the `xxHint` convention the other pattern includes already use (`ssnHint`, `pnHint`, `gnHint`). Adds a spec that parses the include and asserts the relationships rather than literal strings: every control resolves to its own hint, each hint exists, is `usa-sr-only`, and sits in the same form group as its control; the group hint is aria-hidden and referenced by nobody; month labels do not lead with digits; no duplicate ids. Six of its eleven examples fail against the previous markup. Verified on the built page: axe (WCAG2A/AA) reports no violations for the fieldset or the whole page, and the resolved descriptions go from three copies of the shared hint to one sentence per field. Closes uswds#3289
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
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.
Summary
Updated the date of birth pattern so the month, day, and year fields each have their own hint, matching the memorable date component.
Related issue
Closes #3289
Preview link
Preview link: (pending — the deploy preview for this branch)
The pattern appears on Patterns → Create a user profile → Date of birth, in the "Pattern preview" section and in the code sample below it.
Problem statement
Desired state: Someone using a screen reader on the date of birth pattern hears guidance specific to the field they are on — one sentence for the month, one for the day, one for the year.
Actual state: All three fields pointed at the same hint (
id="mdHint"). Moving through the group, a screen reader user heard "For example: January 19 2000" three times and never heard anything about the individual field. The month dropdown also still listed months as "01 - January", which is read aloud as digits that carry no meaning.Consequence: This is the pattern the site recommends other teams copy, so the older markup gets carried into government forms built from it. The memorable date component was fixed in uswds/uswds#6725, but this pattern was left behind, so the site now demonstrates something different from what it recommends.
The component documentation pages pull their markup straight from the USWDS package, so they update themselves. This pattern include is written by hand, which is why it drifted.
Solution
The pattern now follows the same approach as the memorable date component:
A note on naming. The issue suggested hint names in the form
{id}-month-hint. This usesmdMonthHint,mdDayHint, andmdYearHintinstead, because that is the naming every other pattern on this site already uses (ssnHint,pnHint,gnHint, and eleven more). Happy to switch to the wording in the issue if the team prefers it.Two things worth a look during review:
The field names and ids were left alone, so nothing else that refers to them is affected.
Major changes
_includes/patterns/date-of-birth.html— added a hint for each field, hid the group hint from screen readers and updated its wording, removed the leading numbers from the month list._data/changelogs/pattern-user-profile-date-of-birth.yml— added a changelog entry. The date is theNNNN-NN-NNplaceholder and the PR number is blank, both to be filled in at merge.spec/date_of_birth_pattern_spec.rb— new. Checks the pattern keeps its per-field hints so this cannot quietly slip back.Testing and review
Automated
bundle exec rspec— 21 examples, 0 failures (10 already existing, 11 new).npx gulp lintJS lintSass— clean.bundle exec jekyll build— clean.Accessibility
Checked the built page in Chrome with axe (WCAG 2 A/AA) — no violations on the date fields or anywhere else on the page.
aria-valid-attr-value,aria-hidden-focus,duplicate-id,duplicate-id-aria,label, andform-field-multiple-labelsall pass.What each field reports, before and after:
To review it yourself
npm start, then open/patterns/create-a-user-profile/date-of-birth/.Feedback I'm looking for: whether the hint naming should follow the issue's wording instead of the site's existing convention, whether the reworded group hint is wanted here, and confirmation on a real screen reader — the checks above were automated and in-browser, not run with VoiceOver or NVDA.
Note:
pa11y-ciwould not run locally (its bundled browser crashes on Apple silicon), so the same axe checks were run in Chrome directly. CI's own pa11y run should be treated as the final word.