Skip to content

Commit

Permalink
FIX: Correctly intercept <a href target="_self" (discourse#22077)
Browse files Browse the repository at this point in the history
`_self` is the default, so we should treat it the same as having no value specified. This fixes navigation to links like `/my/...` in custom sidebar links.
  • Loading branch information
davidtaylorhq authored Jul 3, 2023
1 parent 9bbfb6e commit 0790e9f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/assets/javascripts/discourse/app/lib/intercept-click.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ export default function interceptClick(e) {

const currentTarget = e.currentTarget;
const href = currentTarget.getAttribute("href");
const linkTarget = currentTarget.getAttribute("target");
const targettingOtherFrame = linkTarget && linkTarget !== "_self";

if (
!href ||
href.startsWith("#") ||
currentTarget.getAttribute("target") ||
targettingOtherFrame ||
currentTarget.dataset.emberAction ||
currentTarget.dataset.autoRoute ||
currentTarget.dataset.shareUrl ||
Expand Down

0 comments on commit 0790e9f

Please sign in to comment.