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

added skip-nav to missing pages #23770

Closed
wants to merge 6 commits into from
Closed

Conversation

Wu-Bowen
Copy link

@Wu-Bowen Wu-Bowen commented May 5, 2020

Description

Added reach-skip-nav IDs to main elements that were missing them.

Documentation

Related Issues

Related to issue #21565

@Wu-Bowen Wu-Bowen requested a review from a team as a code owner May 5, 2020 01:18
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 5, 2020
@Wu-Bowen Wu-Bowen changed the title added reach-skip-nav added skip-nav to missing pages May 5, 2020
@pieh pieh added topic: a11y Related to accessibility topic: website and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels May 5, 2020
@tesseralis tesseralis requested review from 0x80 and madalynrose and removed request for 0x80 May 6, 2020 00:51
Copy link
Contributor

@tesseralis tesseralis left a comment

Choose a reason for hiding this comment

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

Hi @Wu-Bowen! Thanks for your PR.

As I mentioned in the issue, I think the best way to tackle this is by using the <SkipNavContent> component. Using the ID is flaky — if someone mistypes it, it fails silently and the skip link will not work. Using the component means we get a build time error if the component was included incorrectly.

@Wu-Bowen Wu-Bowen requested a review from tesseralis May 6, 2020 21:24
@Wu-Bowen
Copy link
Author

Wu-Bowen commented May 6, 2020

Hi @tesseralis,
Sorry about the component part, I must have missed the comment in the original issue. I changed all the SkipNavContent on the aforementioned pages. I had a question on where some of these pages are used. For example, the 404 page and the ecosystem page are easy enough to find, but for the template pages, I added the component, but I do not know where on the website I can go to test if they are working.

@tesseralis
Copy link
Contributor

One thing I noticed from doing some research on skip-navs (ref: WebAIM a11y-project) was that they tend to be attached to the <main> tag. But Reach's <SkipNavComponent> only renders a div.

After talking with @madalynrose, I think the best solution is to roll out our own <MainContent> component that attaches the ID prop:

function MainContent({ children, …props }) {
  <main id="reach-skip-nav" {…props}>
    {children}
  </main>
}

And then we can use this component in all our pages, replacing the raw reference to ID.

@tesseralis
Copy link
Contributor

As for testing the template pages, check the different files under src/utils/node. These should tell you which pages and urls are associated with which templates. For example, in utils/node/starters:

  starters.forEach((node, index) => {
    createPage({
      path: `/starters${node.fields.starterShowcase.slug}`,
      component: slash(starterTemplate),
      context: {
        slug: node.fields.starterShowcase.slug,
      },
    })
  })

we see that template-starter-page is being used to create pages with the hash /starters/{slug}. So we know it's responsible for making pages like: https://www.gatsbyjs.org/starters/draftbox-co/gatsby-ghost-balsa-starter/

You can also use file search find where different packages are imported. For example, if you search for template-starter-page you should point you to the file in utils/node that uses that template.

@Wu-Bowen
Copy link
Author

@tesseralis Just to understand, you want us to create a MainContent component that will be imported to all the pages. Then, to use this component instead of the id="reach-skip-nav"?

@tesseralis
Copy link
Contributor

@tesseralis Just to understand, you want us to create a MainContent component that will be imported to all the pages. Then, to use this component instead of the id="reach-skip-nav"?

@Wu-Bowen correct!

@Wu-Bowen
Copy link
Author

Hi @tesseralis, we added a new MainContent component and tested it on the pages that you had listed above. Please let us know if this was what you were looking to do and whether or not we should implement it for the rest of the pages.

Copy link
Contributor

@tesseralis tesseralis left a comment

Choose a reason for hiding this comment

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

Excellent start! Yes, this is what I intended and I think we should convert the rest of the files to use this main tag.

Also, can you be sure to run yarn format? Some of the changes are inconsistent with our formatting.

@@ -2,18 +2,21 @@ import React from "react"
import Container from "../components/container"
import Link from "../components/localized-link"
import FooterLinks from "../components/shared/footer-links"
import Main from "../components/main-content"

export default function FourOhFour() {
return (
<>
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this fragment any more since everything is wrapped in a <Main> tag.

@tesseralis
Copy link
Contributor

@Wu-Bowen out of curiousity, what command did you run to format www? It's picking up some formatting errors that weren't picked up before and I'm worried that our linters might be broken.

@Wu-Bowen
Copy link
Author

@Wu-Bowen out of curiousity, what command did you run to format www? It's picking up some formatting errors that weren't picked up before and I'm worried that our linters might be broken.

Yea I noticed that, but I didn't know exactly which files were changed, so I couldn't revert it. I believe I ran yarn prettier --write src/**/*.js. Sorry if this was the wrong command, I wasn't too sure what Gatsby's built-in formatter was.

@tesseralis
Copy link
Contributor

@Wu-Bowen Ah, I see. It appears that our linter hasn't been working for www for the past couple of months. I created a PR to fix that here: #24133.

@tesseralis
Copy link
Contributor

So for now I think we can do one of two things:

  1. wait for that PR to be merged.
  2. undo your formatting changes and try to run prettier on only the files that you are changing.

If you'd rather get unblocked, feel free to do 2. But if you feel that's too much work already and would rather wait, that's fine as well.

@tesseralis
Copy link
Contributor

@Wu-Bowen my eslint PR just got through! Could you fix the conflicts and update this branch? Thanks!

@Wu-Bowen Wu-Bowen requested a review from tesseralis May 19, 2020 22:17
Copy link
Contributor

@tesseralis tesseralis left a comment

Choose a reason for hiding this comment

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

Almost there! Just a couple of changes.

@@ -0,0 +1,11 @@
import React from "react"

const MainContent = ({ children, ...props }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer

export default function MainContent(…)

We've been inconsistent in the past, but going forward we should give components names: https://twitter.com/dan_abramov/status/1255229440860262400

Copy link
Contributor

Choose a reason for hiding this comment

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

In addition, could you write a comment that describes what this component is used for? e.g.:

/**
 * <main> content wrapper that should be included in every page on the site.
 */

@@ -14,6 +15,6 @@ export default function FourOhFour() {
</Link>
</Container>
<FooterLinks />
</>
</Main>
Copy link
Contributor

Choose a reason for hiding this comment

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

<FooterLinks> should not be nested in <main>: https://stackoverflow.com/questions/20470345/should-the-header-and-footer-tags-be-inside-the-main-tag

In general, the components should probably be right next to each other.

@marcysutton marcysutton added the status: awaiting author response Additional information has been requested from the author label Jun 2, 2020
@LekoArts
Copy link
Contributor

Hi @Wu-Bowen 👋 Do you have time to make the requested changes and solve the merge conflict? :)

@freiksenet
Copy link
Contributor

Hi!

I'm going to close this now, as this appears to have been abandoned. Feel free to reopen this PR if you find time to address the comments.

Thanks!

@freiksenet freiksenet closed this Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: awaiting author response Additional information has been requested from the author topic: a11y Related to accessibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants