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

Add "Skip to main content" to content pages #450

Merged
merged 4 commits into from
Mar 2, 2023

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Feb 22, 2023

Fixes

Fixes #449 by @obulat

Description

This PR adds the "skip to main content" link to the content pages (About, Sources, etc).

It also updates the way VSkipToContent works. Instead of focusing on the first tabbable element inside the "main content", it focuses on the "main content" itself. This way, when you click "skip to content", the screenreader reads the main content instead of reading the first link.

Testing Instructions

Go to /about, and press Tab on your keyboard. You should see the "Skip to content" button appear at the top. When you click on it, if screen reader is on, you should hear the first heading or the text of the main content.

Checklist

  • My pull request has a descriptive title (not a vague title like
    Update 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.

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.

This way, when you click on the skip link, the screen reader starts reading the main content instead of the first link or button
@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 Feb 22, 2023
@obulat obulat added 🛠 goal: fix Bug fix and removed ✨ goal: improvement Improvement to an existing user-facing feature labels Feb 22, 2023
@obulat obulat marked this pull request as ready for review February 22, 2023 14:09
@obulat obulat requested a review from a team as a code owner February 22, 2023 14:09
@obulat obulat requested review from dhruvkb and zackkrida and removed request for AetherUnbound and sarayourfriend February 22, 2023 14:09
@zackkrida
Copy link
Member

Just noting: reviewer assignment based on the CODEOWNERS file didn't work properly 😢 I'll add this to the monorepo tasks: #384

@zackkrida zackkrida mentioned this pull request Feb 22, 2023
16 tasks
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.

LGTM. Exciting to review my first frontend PR in the monorepo.

@github-actions
Copy link

github-actions bot commented Feb 24, 2023

Full-stack documentation: Ready

https://WordPress.github.io/openverse/_preview/450

Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again.

You can check the GitHub pages deployment action list to see the current status of the deployments.

@openverse-bot
Copy link
Collaborator

Based on the high urgency of this PR, the following reviewers are being gently reminded to review this PR:

@dhruvkb
This reminder is being automatically generated due to the urgency configuration.

Excluding weekend1 days, this PR was updated 2 day(s) ago. PRs labelled with high urgency are expected to be reviewed within 2 weekday(s)2.

@obulat, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings.

Footnotes

  1. Specifically, Saturday and Sunday.

  2. For the purpose of these reminders we treat Monday - Friday as weekdays. Please note that the that generates these reminders runs at midnight UTC on Monday - Friday. This means that depending on your timezone, you may be pinged outside of the expected range.

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.

Approving, with 1 question

@@ -1,5 +1,5 @@
<template>
<Component :is="as" ref="containerNode">
<Component :is="as" id="main-content" ref="containerNode" tabindex="-1">
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why tabindex was set to -1 was set here. I could be wrong but I thought the default is to set it to 0.

Copy link
Contributor Author

@obulat obulat Mar 2, 2023

Choose a reason for hiding this comment

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

When the user clicks on the "Skip to main content" link, instead of focusing on the first tabbable element, we are now focusing on the element itself. It can be a main or a div, which is normally not focusable, or at least not focusable in older browsers.

I just realized that you weren't asking why there is a tabindex at all, but why it's set to -1, @dhruvkb. It's because the element does not need to be focusable when you simply press Tab, it only needs to be focusable by Javascript.

This article suggests to use the -1 tabindex. It also shows that sometimes it makes sense to focus the h1 and not the main element. We might want to do that in the future, if the current implementation does not work well enough.

@obulat obulat merged commit 0683d91 into main Mar 2, 2023
@obulat obulat deleted the add/skip_to_content_content_page branch March 2, 2023 13:49
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: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "skip to main content" link to all pages
4 participants