Skip to content

Commit 66899eb

Browse files
committed
Comments links now open in new window
1 parent 58e35d3 commit 66899eb

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/public/build
22
public/service-worker.js
33
/node_modules
4-
/public/sw-toolbox.js
4+
/public/sw-toolbox.js
5+
dist/

src/Comment.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ var Comment = React.createClass({
116116
}
117117
},
118118

119+
onCommentClick(e) {
120+
if (e.target.tagName !== 'A') {
121+
this.toggleCollapse(e)
122+
}
123+
else {
124+
e.preventDefault()
125+
window.open(e.target.href, '_blank')
126+
}
127+
},
128+
119129
toggleCollapse(e) {
120130
e.preventDefault()
121131
this.props.threadStore.toggleCollapse(this.state.comment.id)

src/mixins/CommentMixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ var CommentMixin = {
112112
},
113113

114114
renderCommentText(comment, options) {
115-
return <div className="Comment__text" onClick={this.toggleCollapse} >
115+
return <div className="Comment__text" onClick={this.onCommentClick}>
116116
{(!comment.dead || SettingsStore.showDead) ? <div dangerouslySetInnerHTML={{ __html: comment.text }} /> : '[dead]'}
117117
{SettingsStore.replyLinks && options.replyLink && !comment.dead && <p>
118118
<a href={`https://news.ycombinator.com/reply?id=${comment.id}`}>reply</a>

0 commit comments

Comments
 (0)