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

Use more descriptive accessible headings for search result pages #3941

Merged
merged 1 commit into from
Apr 1, 2024

Conversation

sarayourfriend
Copy link
Contributor

@sarayourfriend sarayourfriend commented Mar 20, 2024

Fixes

Fixes #790 by @alexstine (by way of @zackkrida extracting the issue from a tracking issue of several required accessibility fixes)

Description

The large number of added lines come from snapshot tests, not actual code changes. See the testing instructions section for details about these.

The PR adds new sr-only text to the page, as suggested by Alex in the issue. I've chosen to use different variations based on the search type and count of media. In my first attempt, I used two separate h1s. However, this caused an issue with introducing unintended height. Rather than adding additional classes to the second one to prevent that, I decided to just put them inside the same h1, with each bit wrapped in a span so I could mark them as aria-hidden or sr-only as needed. This appears to work in all my testing (ORCA on Linux, NVDA on Windows and VoiceOver on macOS, the latter two in VMs), but please try to break this to make absolutely sure I've got it right.

  • For "all-media" search types, the string is "All results for {query}, {imageResults}, {audioResults}" where the image and audio results are either "No images/audio", "{count} images/audio", or "Over 10000 images/audio". This means the title will inform that the query was for all media types, and the count of results for each media type. That might be too tedious, compared to a unified count, I'm not sure.
  • For individual media types, the string is either "No image results for {query}", "1 image result for {query}", "{count} image results for {query}", or "Over 10000 image results for {query}" where "image" can be either image or audio depending on the search type.

Testing Instructions

Run the application locally using just p frontend dev from the root directory of the repository.

Execute a search from the homepage, and using a screen reader, observe the h1 of the page. Confirm it meets the requirements laid out in the issue.

I used snapshot tests rather than individual assertions for each possibility of the accessible text because otherwise I would have to duplicate the translation, which isn't the point. Ideally this would use a diff snapshot test, render a couple "baseline" variations, and then snapshot diff against those to confirm they are all different in code, but you can do this by reading the snapshots themselves. This is a small component, so the snapshots are not too cumbersome.

I wanted to use inline snapshots, because I've found those easier to work with in the past. However:

  • You cannot use them in an each test
  • Our trailing whitespace pre-commit fix kept trimming whitespace present in the one that isn't in the each block, and I was worried about how many different formatting issue's I'd need to fight against overall. We should disable that trailing whitespace check for anything linted by ruff, prettier, or eslint, though, as it's just duplicating those tools and is less configurable in cases like this... plus, in this case, it was modifying a string literal in the code, which is no good!

Anyway, that's out of scope for this issue. I just wanted to explain the decisions I made there.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • [N/A] I ran the DAG documentation generator (if applicable).

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@github-actions github-actions bot added the 🧱 stack: frontend Related to the Nuxt frontend label Mar 20, 2024
@openverse-bot openverse-bot added 🟧 priority: high Stalls work on the project or its dependents ✨ goal: improvement Improvement to an existing user-facing feature ♿️ aspect: a11y Concerns related to the project's accessibility labels Mar 20, 2024
@sarayourfriend sarayourfriend changed the title Fix/a11y search page headings Use more descriptive accessible headings for search result pages Mar 21, 2024
@sarayourfriend sarayourfriend marked this pull request as ready for review March 22, 2024 03:10
@sarayourfriend sarayourfriend requested review from a team as code owners March 22, 2024 03:10
Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

Tried it locally and it works well. I have some subjective opinions but not worth blocking the PR over.

But, if all that's changed is a11y of search headings, the changes to the snapshots are unwarranted. Looking into the changes it seems like the changes are due to font size differences, different shades of grey in checkboxes, and difference in waveforms of audio results. Maybe they are flakes and the checks will still pass if they are reverted?

.pre-commit-config.yaml Show resolved Hide resolved
frontend/jest.config.js Outdated Show resolved Hide resolved
frontend/src/components/VSearchResultsTitle.vue Outdated Show resolved Hide resolved
Comment on lines 466 to 627
count: "{localeCount} audio",
countMore: "over {localeCount} audio",
Copy link
Member

Choose a reason for hiding this comment

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

Subjective opinion: Number with 'audio' felt wrong.

Suggested change
count: "{localeCount} audio",
countMore: "over {localeCount} audio",
count: "{localeCount} audio tracks",
countMore: "over {localeCount} audio tracks",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in db46a04

Copy link
Member

Choose a reason for hiding this comment

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

@sarayourfriend I believe "tracks" is still missing in the cases where the string is All results for "zack", 10 images and 10 audio.

frontend/src/locales/scripts/en.json5 Show resolved Hide resolved
@fcoveram fcoveram removed their request for review March 25, 2024 08:56
@obulat
Copy link
Contributor

obulat commented Mar 25, 2024

@sarayourfriend, I'm drafting this PR to prevent pings while the comments on prettier and snapshot changes are addressed.

@obulat obulat marked this pull request as draft March 25, 2024 15:27
@sarayourfriend sarayourfriend marked this pull request as ready for review March 26, 2024 03:37
@sarayourfriend
Copy link
Contributor Author

@obulat @dhruvkb This is ready for review.

Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

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

Looks great. Requesting one small change for the last place where "tracks" is missing after "audio", and a non-blocking suggestion for code readability in the unit test.

Comment on lines 466 to 627
count: "{localeCount} audio",
countMore: "over {localeCount} audio",
Copy link
Member

Choose a reason for hiding this comment

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

@sarayourfriend I believe "tracks" is still missing in the cases where the string is All results for "zack", 10 images and 10 audio.

@zackkrida zackkrida marked this pull request as draft March 26, 2024 18:24
@sarayourfriend sarayourfriend marked this pull request as ready for review March 26, 2024 22:28
Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

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

Great 👍 I appreciate the unit test improvements as well, like adding the translation job and excluding the tailwind prettier plugin

Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

I tested this PR on NVDA and VoiceOver.

NVDA reads the heading, and you can get to the heading using the H shortcut.
In VoiceOver, you have to navigate inside the heading element to read the heading using the shortcut (VO+command+H). If you try the same shortcut when the VO focus area is in the content area (one level above), it says "Heading not found". I'm not sure if it's supposed to be like that, or if I'm using VO incorrectly, or if VO has a bug, but I couldn't find a way to navigate through the headings on the search page.

@@ -14,7 +14,8 @@ module.exports = {
{
files: ["frontend/**/*"],
options: {
plugins: ["prettier-plugin-tailwindcss"],
// Do not include tailwind plugin in test environment, as it breaks jest
Copy link
Contributor

Choose a reason for hiding this comment

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

Great find!

type KeyCollection = {
zero: string
count: string
countMore: string
Copy link
Contributor

Choose a reason for hiding this comment

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

Much better naming ✨

@zackkrida
Copy link
Member

A few snapshots need updating after the merge of #3967

@sarayourfriend
Copy link
Contributor Author

I had to squash this PR, the back-and-forth commits were making rebases a pain. I should be able to merge this now so long as CI passes, there are no changes other than updates to the snapshots that Zack mentioned.

@sarayourfriend sarayourfriend merged commit a51ac8d into main Apr 1, 2024
39 checks passed
@sarayourfriend sarayourfriend deleted the fix/a11y-search-page-headings branch April 1, 2024 23:37
Collins-Webdev added a commit to Collins-Webdev/openverse that referenced this pull request Apr 4, 2024
Hi there,

I've made some enhancements to the code to address the issue described in WordPress#3941. Following the convention established, I updated references to audio works to use the phrase "audio track(s)" instead of just "audio".

Please review the changes and let me know if there are any further adjustments needed. Thank you for considering my contribution.
obulat pushed a commit to Collins-Webdev/openverse that referenced this pull request Apr 29, 2024
Hi there,

I've made some enhancements to the code to address the issue described in WordPress#3941. Following the convention established, I updated references to audio works to use the phrase "audio track(s)" instead of just "audio".

Please review the changes and let me know if there are any further adjustments needed. Thank you for considering my contribution.
obulat pushed a commit to Collins-Webdev/openverse that referenced this pull request Apr 30, 2024
Hi there,

I've made some enhancements to the code to address the issue described in WordPress#3941. Following the convention established, I updated references to audio works to use the phrase "audio track(s)" instead of just "audio".

Please review the changes and let me know if there are any further adjustments needed. Thank you for considering my contribution.
obulat pushed a commit to Collins-Webdev/openverse that referenced this pull request Apr 30, 2024
Hi there,

I've made some enhancements to the code to address the issue described in WordPress#3941. Following the convention established, I updated references to audio works to use the phrase "audio track(s)" instead of just "audio".

Please review the changes and let me know if there are any further adjustments needed. Thank you for considering my contribution.
obulat added a commit that referenced this pull request Apr 30, 2024
* Issue #3941 resolved

Hi there,

I've made some enhancements to the code to address the issue described in #3941. Following the convention established, I updated references to audio works to use the phrase "audio track(s)" instead of just "audio".

Please review the changes and let me know if there are any further adjustments needed. Thank you for considering my contribution.

* Grammatical issues resolved.

* Fixed grammatical issues

* Fix linting error

* Suggestions added

* Changes made.

* Changes made.

* Remove unnecessary 'files'

* Changes made.

* Add trailing blank line

* Add missing space

* Add a missing article

Signed-off-by: Olga Bulat <obulat@gmail.com>

* Update snapshots

Signed-off-by: Olga Bulat <obulat@gmail.com>

---------

Signed-off-by: Olga Bulat <obulat@gmail.com>
Co-authored-by: Olga Bulat <obulat@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
♿️ aspect: a11y Concerns related to the project's accessibility ✨ goal: improvement Improvement to an existing user-facing feature 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: frontend Related to the Nuxt frontend
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

More descriptive screen reader text for search page headings
5 participants