Skip to content

fix(Link): respect target on links to app routes - #1341

Open
jelic-nikola wants to merge 1 commit into
masterfrom
fix/link-respect-target
Open

jelic-nikola wants to merge 1 commit into
masterfrom
fix/link-respect-target

Conversation

@jelic-nikola

Copy link
Copy Markdown
Contributor

Problem

Link and LinkButton ignored target when href pointed to a route in the app (~/…). A link with target="_blank" changed the route in the current tab instead of opening a new one. Only a Ctrl-, Shift- or Cmd-click opened a new tab.

Change

The app now handles the click itself only when target is empty or _self. For any other target, the browser follows the link:

  • _blank opens a new tab.
  • A named target (e.g. "report") opens a window with that name, and reuses it on later clicks.
  • _parent and _top load the page in the parent or top window when the app runs in an iframe.

Links without a target, or with _self, change the route in the app as they do now. React Router handles link clicks the same way.

Behaviour change

_parent or _top on a link to an app route, in a page that is not inside an iframe, now reloads the page at that URL instead of changing the route in the app. This follows what target means in HTML.

How to test

Run yarn litmus, which opens the bugs/link-target page. The link without a target changes the URL in the same tab. The _blank links open a new tab, and the URL in the current tab stays the same. The named-window link opens a tab called report on the first click, and reuses it after that.

@jelic-nikola
jelic-nikola requested a review from mstijak October 16, 2026 11:53
@jelic-nikola jelic-nikola self-assigned this Oct 16, 2026

This branch has not been deployed

No deployments
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