Skip to content

Inertia Link override: no aria-current, invalid ariacurrentvalue attribute, and prefix-based active matching #6803

Description

@kodjosama

Environment

  • @nuxt/ui 4.10.0
  • Vue + Vite (no Nuxt), Inertia.js v2, plugin configured as ui({ router: 'inertia' })
  • File under discussion: dist/runtime/vue/overrides/inertia/Link.vue
  • Comparison point: dist/runtime/vue/overrides/vue-router/Link.vue

Description

The router: 'inertia' Link override diverges from the vue-router one in three ways. Because every Nuxt UI component that renders a link (UButton, UBreadcrumb, UNavigationMenu, UDropdownMenu, …) goes through this component, all three affect the whole library in Inertia mode.

1. aria-current is never emitted

isLinkActive (inertia/Link.vue:109-123) only feeds linkClass (:124-130) and the active slot prop. The rendered anchor never receives aria-current.

The vue-router variant does emit it (vue-router/Link.vue:119 and :136):

...exact && isExactActive ? { 'aria-current': props.ariaCurrentValue } : {},

The Inertia variant has no equivalent, so an Inertia app that migrates its navigation onto Nuxt UI silently loses the current-page announcement for screen-reader users.

2. ariaCurrentValue leaks onto the DOM as an invalid attribute

ariaCurrentValue is declared with a default (inertia/Link.vue:26):

ariaCurrentValue: { type: String, required: false, default: "page" },

but it is not in the reactiveOmit list at :71:

const routerLinkProps = useForwardProps(reactiveOmit(props, "as", "type", "disabled", "active", "exact", "activeClass", "inactiveClass", "to", "href", "raw", "custom", "class", "target", "rel", "noRel"));

so useForwardProps passes it to ULinkBase (:150-166), which does not declare it either, so it lands in $attrs and reaches the DOM as ariacurrentvalue="page".

vue-router/Link.vue omits it from its reactiveOmit list too, but there it is harmless: RouterLink declares ariaCurrentValue as a real prop and consumes it. inertia/LinkBase.vue (and @inertiajs/vue3's Link) declare no such prop.

Because the prop carries a default, the attribute appears even on components that render no link at all. Measured on a page with three Nuxt UI components — one <UButton to> and two <UButton> with no to — all three rendered ariacurrentvalue="page", client-side and in SSR output.

Minimal repro:

<UButton>no link at all</UButton>
<!-- renders: <button ... ariacurrentvalue="page"> -->

3. Active matching uses a raw prefix against a query-carrying URL

inertia/Link.vue:119:

if (!props.exact && page.url.startsWith(href.value)) {
  return true;
}

usePage().url in Inertia includes the query string, and startsWith is a raw prefix test. Three consequences:

  • A query string defeats the match. page.url = '/inventory?search=x' with to="/inventory" is active (prefix holds), but to="/inventory" on page.url = '/inventory?search=x' where the link itself carries a query — or any link whose href is longer than the bare path — is not. More importantly the reverse case, to="/inventory/adjust" while on /inventory?tab=1, behaves unpredictably.
  • to="/" is active on every page, since every URL starts with /.
  • Segment boundaries are ignored: to="/inventory" reports active on /inventory-adjustments.

The vue-router variant delegates this to RouterLink's isActive/isExactActive, which are path- and segment-aware, so the Inertia variant is the odd one out.

Suggested fix

  1. Add ...isLinkActive ? { 'aria-current': props.ariaCurrentValue } : {} to the two v-bind objects in inertia/Link.vue's template (absent, not "false", when inactive).
  2. Add "ariaCurrentValue" to the reactiveOmit list at :71.
  3. Compare on the path only, with segment boundaries:
const pathOf = (url) => {
  const path = url.split('#')[0].split('?')[0]
  return path.length > 1 && path.endsWith('/') ? path.slice(0, -1) : path || '/'
}

// non-exact
const current = pathOf(page.url)
const target = pathOf(href.value)
return target === '/' ? current === '/' : current === target || current.startsWith(`${target}/`)

Happy to open a PR for this if the approach looks right.

Additional context

We are carrying this as a local build-time patch on the vendored module while migrating a production Inertia app onto Nuxt UI, and would rather drop it than maintain it.

Activity

  1. coderabbitai commented on Aug 6, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #6628 - fix(components): forward $attrs to root element when to prop is absent [merged]
    #6637 - fix(Link): fall back to original path when localePath fails [merged]
    #6640 - fix(ContentNavigation): key items by identity to prevent leading icon flash [merged]
    #6668 - fix(Button): allow inline event handlers with non-void return types [merged]
    #6677 - fix(Link): apply rel prop to internal links [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. kodjosama commented on Aug 7, 2026

    @kodjosama
    Author

    Opened #6809 with a fix for all three points, plus the missing test harness — the vue vitest project resolves #components to the vue-router overrides only, so the inertia directory was never loaded by any test. That's presumably how the three defects coexisted.

    One correction to my own report: I listed to="/" being active everywhere as a defect. With segment-aware matching that's just / being a parent of every route, which is what RouterLink does too — so the PR keeps that behaviour and exact stays the way to make a home link exclusive. The real defect there was the segment-blindness (/inventory matching /inventory-adjustments), which is fixed.

    For aria-current the PR mirrors the vue-router condition exactly (exact && isExactActive) rather than introducing a different policy for Inertia, since parity is the point of this report. If you'd rather emit it on exact-active regardless of the exact prop, that looks like a change for both variants together and I'm happy to follow up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageAwaiting initial review and prioritization

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions