Skip to content

Commit f04300b

Browse files
committed
fix s270
1 parent 909dfe8 commit f04300b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/shared/components/Contentful/Article/Article.jsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ class Article extends React.Component {
148148
},
149149
).substring(0, CONTENT_PREVIEW_LENGTH);
150150
const catsGrouped = _.groupBy(fields.contentCategory, cat => cat.fields.trackParent);
151+
// captures clicks on article
152+
// for opening external links in new tab
153+
const articleClickHandler = (e) => {
154+
if (e.target.href && fields.openExternalLinksInNewTab !== false) {
155+
const target = new URL(e.target.href);
156+
if (!target.host.includes('topcoder')) {
157+
window.open(e.target.href, '_blank');
158+
e.preventDefault();
159+
}
160+
}
161+
};
151162

152163
return (
153164
<React.Fragment>
@@ -291,7 +302,12 @@ class Article extends React.Component {
291302
</div>
292303
</div>
293304
{/* Content */}
294-
<div className={theme.articleContent}>
305+
<div
306+
className={theme.articleContent}
307+
role="presentation"
308+
onClick={articleClickHandler}
309+
onKeyPress={articleClickHandler}
310+
>
295311
<MarkdownRenderer markdown={fields.content} {...contentfulConfig} />
296312
{
297313
fields.type === 'Video' && fields.contentUrl ? (

0 commit comments

Comments
 (0)