Search results: Update Results description with Structure and Code guidance - #6167
Search results: Update Results description with Structure and Code guidance#6167derekwang99 with Copilot wants to merge 3 commits into
Conversation
…ubsections Agent-Logs-Url: https://github.com/department-of-veterans-affairs/vets-design-system-documentation/sessions/c6847155-6938-46cd-aa95-daa6a63d8d10 Co-authored-by: derekwang99 <57509494+derekwang99@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the shared “results description” guidance used by the Search results template (and other pages that include it) to better document the expected text structure and accessibility-oriented implementation considerations.
Changes:
- Reorganizes the “Results description” content into “Structure” and “Code guidance” subsections.
- Documents the canonical results description string format and variants (non-search contexts, filtered results).
- Adds developer guidance for focus management and live-region announcements (
role="status",tabindex="-1", avoiding inline elements).
| * Using `role="status"` provides an implicit `aria-live="polite"`, which will announce updates when the content changes. Adding an explicit `aria-live` is not necessary. | ||
| * To support programmatic focus, `tabindex="-1"` is required if we intend to move focus to the results description element. This is a focus-driven announcement pattern and is separate from live region behavior. | ||
| * When moving focus to the results description, the content should be announced as a single unit, assuming the DOM update is atomic. In testing (especially with VoiceOver), inline elements such as `<strong>`, `<span>`, etc., can cause the content to be announced in fragmented chunks instead of a single cohesive sentence, even though this is not consistently expected behavior. | ||
| * Avoid inline stylistic elements within the results description when possible, and instead rely on plain text to ensure consistent, single-pass announcements across assistive technologies. If inline styling is required, additional measures such as `aria-atomic="true"` may help, but results can still vary across screen readers. |
There was a problem hiding this comment.
The aria-atomic="true" suggestion is a bit confusing alongside the recommendation to use role="status": elsewhere in the docs role="status" is described as implicitly setting aria-atomic="true" already. Consider clarifying that role="status" includes aria-atomic, and only suggest adding aria-atomic when using a different live-region approach.
| * Avoid inline stylistic elements within the results description when possible, and instead rely on plain text to ensure consistent, single-pass announcements across assistive technologies. If inline styling is required, additional measures such as `aria-atomic="true"` may help, but results can still vary across screen readers. | |
| * Avoid inline stylistic elements within the results description when possible, and instead rely on plain text to ensure consistent, single-pass announcements across assistive technologies. If inline styling is required and you are using a live region approach other than `role="status"`, `aria-atomic="true"` may help, but results can still vary across screen readers. |
There was a problem hiding this comment.
Im not the best person to make the call on whether to commit this suggestion so feedback is welcome.
|
@derekwang99 - I see this is still in draft mode - are you ready for our review? |
| The implementation should follow this format: | ||
|
|
||
| * **Update when filters change.** The results description must update when filters are changed so that all users can understand that the results have been updated. Implementation should follow this format: | ||
| * Showing 1–10 of 999 for "[query]" |
There was a problem hiding this comment.
should this say "results" ? showing 1-10 of 999 what?
Maybe there was a content decision to leave off the noun, and I trust the content folks. it just feels weird not not have the noun/object of the search displayed
| * **Do not reflect changes to sort.** The Sort component itself acts as the visual indicator of the order. | ||
| * An `<h2>` is not required for the results description. Some implementations on VA.gov may use this convention, but this is discouraged. A stable, targetable element (e.g., ID) is sufficient for focus management. | ||
| * Using `role="status"` provides an implicit `aria-live="polite"`, which will announce updates when the content changes. Adding an explicit `aria-live` is not necessary. | ||
| * To support programmatic focus, `tabindex="-1"` is required if we intend to move focus to the results description element. This is a focus-driven announcement pattern and is separate from live region behavior. |
There was a problem hiding this comment.
Is the intent here to use a live region and to move focus at the same time to the results description? This seems like it would be redunandant? Moving focus to the description would also cause it to be announced. And the role="status" with the implicit aria-live would also cause it to be announced.
💬Hello! This PR is to add code guidance to implementing a results description. Main problem is that result descriptions (like on Search or Find a Form) use
<h2>for some reason and should instead be plain text. Additionally, screen readers announce the results description in a fragmented way. A MHV engineer wrote new guidance to mitigate these issues for future engineers when developing result descriptions. Note that in terms of visual changes the "[query]" portion will need to be unbolded (is currently in Figma Search Results template)(rest of this is generated by Copilot)
The Results description section lacked format guidance and accessibility/coding best practices, leaving teams to infer implementation details from existing VA.gov examples (some of which use an unnecessary
<h2>).Changes
src/_includes/components/results-description.md— Restructured content into two subsections:Structure
Clarifies the canonical format and its variants:
Showing 1–10 of 999 for "[query]"for "[query]"(e.g., medications, appointments)with X filters applied; sorting doesn't require it since the Sort component is the visual indicatorCode guidance
Seven developer-facing bullets from accessibility testing findings:
<h2>is not required — a stable element with an ID is sufficient for focus managementrole="status"gives implicitaria-live="polite"; no explicitaria-liveneededtabindex="-1"is required to support programmatic focus<strong>,<span>, etc.) can fragment VoiceOver announcements — prefer plain textaria-atomic="true"may help when inline styling is unavoidable, but screen reader behavior variesExample implementation:
Original prompt
Create a PR to update the “Results description” section of the Search results template documentation page so it matches the structure and guidance below.
Target page (docs site): https://design.va.gov/templates/search-results#results-description
Repository: department-of-veterans-affairs/vets-design-system-documentation
Related issue:
Desired new content/structure
Replace/restructure the existing “results description” section so it has:
Results description
Text describing how many results are being shown.
Structure
The implementation should follow this format:
Code guidance
is not required for the results description. Some implementations on VA.gov may use this convention, but this is not necessary. A stable, targetable element (e.g., ID) is sufficient for focus management.
Implementation notes
PR expectations
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Help me create a PR that will edit the result description section in the search results template: https://design.va.gov/templates/search-results#results-description.
Restructure that section so that this is the new structure
Results description
Text describing how many results are being shown.
Structure
The implementation should follow this format:
Code guidance
is not required for the results description. Some implementations on VA.gov may use this convention, but this is not necessary. A stable, targetable element (e.g., ID) is sufficient for focus management.
This pull request was created from Copilot chat.
Open Preview Environment