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 {
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 ? (
You can’t perform that action at this time.
0 commit comments