-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Conversation
There was a problem hiding this 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.
Hi @tesseralis, |
One thing I noticed from doing some research on skip-navs (ref: WebAIM a11y-project) was that they tend to be attached to the After talking with @madalynrose, I think the best solution is to roll out our own 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. |
As for testing the template pages, check the different files under starters.forEach((node, index) => {
createPage({
path: `/starters${node.fields.starterShowcase.slug}`,
component: slash(starterTemplate),
context: {
slug: node.fields.starterShowcase.slug,
},
})
}) we see that You can also use file search find where different packages are imported. For example, if you search for |
@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! |
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. |
There was a problem hiding this 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.
www/src/pages/404.js
Outdated
@@ -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 ( | |||
<> |
There was a problem hiding this comment.
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.
@Wu-Bowen out of curiousity, what command did you run to format |
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. |
So for now I think we can do one of two things:
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. |
@Wu-Bowen my eslint PR just got through! Could you fix the conflicts and update this branch? Thanks! |
There was a problem hiding this 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 }) => { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
Hi @Wu-Bowen 👋 Do you have time to make the requested changes and solve the merge conflict? :) |
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! |
Description
Added reach-skip-nav IDs to main elements that were missing them.
Documentation
Related Issues
Related to issue #21565