File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
src/shared/components/Contentful/Article Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,17 @@ class Article extends React.Component {
148
148
} ,
149
149
) . substring ( 0 , CONTENT_PREVIEW_LENGTH ) ;
150
150
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
+ } ;
151
162
152
163
return (
153
164
< React . Fragment >
@@ -291,7 +302,12 @@ class Article extends React.Component {
291
302
</ div >
292
303
</ div >
293
304
{ /* Content */ }
294
- < div className = { theme . articleContent } >
305
+ < div
306
+ className = { theme . articleContent }
307
+ role = "presentation"
308
+ onClick = { articleClickHandler }
309
+ onKeyPress = { articleClickHandler }
310
+ >
295
311
< MarkdownRenderer markdown = { fields . content } { ...contentfulConfig } />
296
312
{
297
313
fields . type === 'Video' && fields . contentUrl ? (
You can’t perform that action at this time.
0 commit comments