fix: External links in widget not opening in new tab (#11608)

This commit is contained in:
Sivin Varghese
2025-05-28 15:15:05 +05:30
committed by GitHub
parent b1120ae7fb
commit dc335e88c9
2 changed files with 99 additions and 10 deletions

View File

@@ -38,16 +38,9 @@ export const openExternalLinksInNewTab = () => {
document.addEventListener('click', event => {
if (!isOnArticlePage) return;
// Some of the links come wrapped in strong tag through prosemirror
const isTagAnchor = event.target.tagName === 'A';
const isParentTagAnchor =
event.target.tagName === 'STRONG' &&
event.target.parentNode.tagName === 'A';
if (isTagAnchor || isParentTagAnchor) {
const link = isTagAnchor ? event.target : event.target.parentNode;
const link = event.target.closest('a');
if (link) {
const isInternalLink =
link.hostname === window.location.hostname ||
link.href.includes(customDomain) ||