Repository navigation
fix(Link): respect target on links to app routes - #1341
Open
jelic-nikola wants to merge 1 commit into
Open
jelic-nikola wants to merge 1 commit into
jelic-nikola wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
LinkandLinkButtonignoredtargetwhenhrefpointed to a route in the app (~/…). A link withtarget="_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
targetis empty or_self. For any other target, the browser follows the link:_blankopens a new tab."report") opens a window with that name, and reuses it on later clicks._parentand_topload 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
_parentor_topon 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 whattargetmeans in HTML.How to test
Run
yarn litmus, which opens thebugs/link-targetpage. The link without a target changes the URL in the same tab. The_blanklinks open a new tab, and the URL in the current tab stays the same. The named-window link opens a tab calledreporton the first click, and reuses it after that.