Skip to content

feat: add skip to content link for keyboard-first visitors #347

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

Merged
merged 4 commits into from
Jun 24, 2025

Conversation

chrisvogt
Copy link
Owner

This PR reattempts #212 and adds a skip navigation link to the home and page templates.

AI summary

This pull request introduces a new accessibility feature, a "Skip to content" link, for improved navigation by keyboard-first users. It also includes related updates to the codebase, tests, and documentation. Below is a breakdown of the most important changes grouped by theme.

Accessibility Feature: "Skip to Content" Link

  • Added SkipNavLink and SkipNavContent components from the @reach/skip-nav library to the Layout and HomeTemplate components, enabling users to skip directly to the main content. (theme/src/components/layout.js, theme/src/templates/home.js) [1] [2] [3] [4] [5]
  • Updated styles by importing @reach/skip-nav/styles.css in gatsby-browser.js. (theme/gatsby-browser.js)

Navigation Behavior Enhancements

  • Implemented an onRouteUpdate function to focus the main content (SkipNavContent) after a route change, improving accessibility for keyboard users. (theme/gatsby-browser.js)

Testing

  • Added comprehensive unit tests for shouldUpdateScroll and onRouteUpdate functions, including mock implementations for DOM manipulation. (theme/gatsby-browser.spec.js)

Documentation and Versioning

  • Updated the CHANGELOG.md to document the new feature in version 0.45.0. (CHANGELOG.md)
  • Updated the package.json version to 0.45.0 and added @reach/skip-nav as a dependency. (theme/package.json) [1] [2]

Snapshot Updates

  • Updated Jest snapshots to reflect the addition of the "Skip to content" link and the SkipNavContent element. (theme/src/components/__snapshots__/layout.spec.js.snap) [1] [2] [3]

Copy link

netlify bot commented Jun 24, 2025

Deploy Preview for chrisvogt ready!

Name Link
🔨 Latest commit dc4b711
🔍 Latest deploy log https://app.netlify.com/projects/chrisvogt/deploys/685a1f079bdf240008e2734b
😎 Deploy Preview https://deploy-preview-347--chrisvogt.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

codecov bot commented Jun 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.62%. Comparing base (11dc51c) to head (dc4b711).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #347   +/-   ##
=======================================
  Coverage   96.62%   96.62%           
=======================================
  Files          76       76           
  Lines         888      889    +1     
  Branches      242      243    +1     
=======================================
+ Hits          858      859    +1     
  Misses         26       26           
  Partials        4        4           
Flag Coverage Δ
unittests 96.62% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chrisvogt
Copy link
Owner Author

The deploy preview looks great. I'm going to merge this.

Screen.Recording.2025-06-23.at.8.47.02.PM.mov

@chrisvogt chrisvogt merged commit 8c987fb into main Jun 24, 2025
12 checks passed
@chrisvogt chrisvogt deleted the add-skip-nav branch June 24, 2025 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant