Skip to content

fix(vue-action): follow the RouterLink on click, parse string to, disable links without href - #316

Merged
dadajam4 merged 1 commit into
mainfrom
fix/vue-action-router-link-navigation
Oct 1, 2026
Merged

dadajam4 merged 1 commit into
mainfrom
fix/vue-action-router-link-navigation

Conversation

@dadajam4

@dadajam4 dadajam4 commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Fixes #314.
Fixes #315.

Problem

Change

@fastkit/vue-action (minor)

  • A click calls the slot's navigate() (Option B in vue-action: navigation on click can diverge from the rendered href of the RouterLink #314). It is called without the event: the click handler has already prevented its default, and Vue Router's navigate ignores such events. When the slot has no navigate, the previous router.push and registerRouteActionHandler are used. NuxtLink's custom slot provides navigate and it matches the href.
  • String to: the hash keeps its #; the query goes through Vue Router's parseQuery; a to with a protocol, or a protocol-relative one, is rendered as a plain <a href>. isExternalLocation() is exported.
  • A disabled link (to or href) is rendered without href, with role="link" and aria-disabled="true", and without disabled. It is not focusable, like a disabled button. Enabled links get no explicit role, since it would be redundant. Buttons keep disabled.

Impact

  • registerRouteActionHandler is only called in the fallback. A handler that existed only to keep the navigation in sync with the RouterLink is no longer needed.
  • Styles that select a disabled link with [disabled] no longer match; [aria-disabled='true'] does. @fastkit/vui already selects both. The changeset says this.

Verification

  • New tests in packages/vue-action/src/__tests__/:
    • utils.spec.ts: the cases from vue-action: string to breaks the hash, the query, and absolute URLs #315 resolved with Vue Router, plus isExternalLocation.
    • actionable.client.spec.ts:
      • a RouterLink wrapper that appends a trailing slash: the click lands on the rendered href;
      • replace still works;
      • the handler fallback when the slot has no navigate;
      • a protocol to is rendered as a plain link;
      • disabled links with to, a protocol to and href have no href and do not navigate;
      • buttons keep disabled.
  • The tests for the bugs fail against the code on main. The replace, fallback and button tests pass on both, as regression guards.
  • pnpm typecheck; lint, build and tests for vue-action; typecheck and tests for vui.

🤖 Generated with Claude Code

…isable links without `href`

- Navigate with the `navigate` function the RouterLink passes to its slot, so
  a click goes where the rendered `href` points. `router.push` and
  `registerRouteActionHandler` remain as the fallback when the slot has no
  `navigate`. (#314)
- Keep the leading `#` of the hash, parse the query with Vue Router's
  `parseQuery`, and render a `to` with a protocol as a plain `<a href>`
  instead of joining it to the current path. Export `isExternalLocation`.
  (#315)
- Render a disabled link without `href`, with `role="link"` and
  `aria-disabled="true"`, and drop the `disabled` attribute that `<a>` does
  not have. A disabled link could still be followed with a modifier key, a
  middle click or `target`, and a disabled `href` link without `guard` or
  `onClick` on a plain click.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 25ac70a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@fastkit/vue-action Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dadajam4
dadajam4 merged commit ef740ad into main Oct 1, 2026
1 check passed
@dadajam4
dadajam4 deleted the fix/vue-action-router-link-navigation branch October 1, 2026 13:47
@github-actions github-actions Bot mentioned this pull request Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant