Skip to content

Commit 9c7b527

Browse files
committed
Fix duplicate article links
1 parent 4d42b98 commit 9c7b527

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/utils/update-article-links.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ export function updateArticleLinks(doc: Document): number {
3636
const newHref = buildArticleUrl(ARTICLE_LINK_MAP[matchedId]);
3737

3838
anchorEl.setAttribute('href', newHref);
39+
40+
// Prevent Zendesk's internal click handler from intercepting navigation.
41+
// We use capture phase so our handler fires before Zendesk's handlers on
42+
// the element. Guard against duplicate listeners on repeated calls.
43+
if (!anchorEl.dataset.helpPageRewritten) {
44+
anchorEl.dataset.helpPageRewritten = 'true';
45+
anchorEl.addEventListener(
46+
'click',
47+
(event) => {
48+
event.preventDefault();
49+
event.stopImmediatePropagation();
50+
window.open(
51+
anchorEl.getAttribute('href') ?? newHref,
52+
'_blank',
53+
'noopener,noreferrer',
54+
);
55+
},
56+
true,
57+
);
58+
}
59+
3960
updatedCount++;
4061
}
4162
});

0 commit comments

Comments
 (0)