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

Link Component affects tab order when using anchors affecting accessibility #74249

Open
apricot13 opened this issue Dec 23, 2024 · 0 comments
Open
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@apricot13
Copy link

apricot13 commented Dec 23, 2024

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/modest-babbage-ywzvtv

To Reproduce

I've included a version using <a href="#"> and <Link href="#"> in my example above

Steps to replicate:

  • Tab to the any item in the sidebar and hit enter
  • Keep hitting tab again

Current vs. Expected behavior

When using plain html links <a href="#"> the behaviour of the page is expected to be: tab to a link with an anchor and hit enter - tabbing continues from that point on the page

with-html-link

When using <Link href="#"> however the behaviour is to continue from where you were tabbing before you hit enter so you lose context, this was flagged in one of our accessibility audits.

with-nextjs-link

The documentation doesn't mention anything special about anchor link functionality

I've tried additional settings eg using /path#anchor instead of #anchor I've also tried href={{ hash: 'anchor' }}.

If you go directly to an anchor link url tabbing begins as expected on both versions

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.1.1-canary.17 // Latest available version is detected (15.1.1-canary.17).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Navigation

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Other (Deployed)

Additional context

This was flagged up in our accessibility audit - our fix for now is to use <a href="#">

@apricot13 apricot13 added the bug Issue was opened via the bug report template. label Dec 23, 2024
@github-actions github-actions bot added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

No branches or pull requests

1 participant