Skip to content

Link does not fire onClick / onPress when activated via keyboard (Tab + Enter), causing full page reload with third-party routers #9868

@lyhoang-web-dev

Description

@lyhoang-web-dev

Provide a general summary of the issue here

When a React Aria Link is focused via Tab and activated via Enter, neither onClick nor onPress is fired. This prevents 3rd-party routers (e.g. TanStack Router) from intercepting navigation and calling e.preventDefault(), causing the browser to fall back to native href navigation — resulting in a full page reload instead of SPA client-side navigation.

Mouse click works correctly: both onClick and onPress fire as expected.

🤔 Expected Behavior?

Pressing Enter on a focused Link should fire both onClick and onPress, identical to mouse click behavior.

<Link
  href="/development"
  onClick={() => console.log("onClick fired")} // ✅ should fire on keyboard Enter
  onPress={() => console.log("onPress fired")} // ✅ should fire on keyboard Enter
>
  Development
</Link>

Third-party routers that rely on onClick + e.preventDefault() (e.g. TanStack Router) should be able to intercept the event and perform client-side navigation without a full page reload.

😯 Current Behavior

When the link is activated via keyboard (Tab to focus → Enter to activate):

  • onClick is not fired
  • onPress is not fired
  • Browser follows the href natively → full page reload

When activated via mouse click:

  • onClick fires ✅
  • onPress fires ✅
  • SPA navigation works correctly ✅

This affects both integration approaches documented in TanStack Router's custom link guide:

// Approach 1 — createLink()
const CustomLink = createLink(AriaLink);
<CustomLink to="/development">Development</CustomLink>

// Approach 2 — _asChild (internal API)
<RouterLink to="/development" _asChild={AriaLink}>
  Development
</RouterLink>

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

Plain React Aria reproduction (no TSR):

  1. Open: https://stackblitz.com/edit/skmzpfdr?file=src%2FExample.tsx
  2. Open the browser console
  3. Click a link with the mouse → observe onClick and onPress logged ✅
  4. Focus the same link with Tab and press Enter → observe nothing logged ❌

With TanStack Router integration:

  1. Open: https://stackblitz.com/edit/vitejs-vite-2xxlupse
  2. Click a link with the mouse → SPA navigation, no page reload ✅
  3. Focus a link with Tab and press Enter → full page reload ❌

Version

1.16.0

What browsers are you seeing the problem on?

Microsoft Edge

If other, please specify.

No response

What operating system are you using?

Window

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions