Skip to content

Commit 2bde429

Browse files
committed
check on scrollTo
1 parent f7ea424 commit 2bde429

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/projects/detail/containers/SingleFeedContainer.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,18 @@ class SingleFeedContainer extends React.Component {
4545
}
4646

4747
componentDidMount() {
48-
// we use this to just scroll to a feed block or comment in a feed block, if there is a url hash
48+
// we use this to just scroll to a feed block or comment in a feed block,
49+
// only if there is a url hash and the feed id and comment id match this feed
4950
const scrollTo = window.location.hash ? window.location.hash.substring(1) : null
5051
if (scrollTo) {
51-
setTimeout(() => scrollToHash(scrollTo), 100)
52+
const hashParts = _.split(scrollTo, '-')
53+
const hashId = parseInt(hashParts[1], 10)
54+
if (
55+
(hashParts[0] === 'feed' && hashId === this.props.id) ||
56+
(hashParts[0] === 'comment' && this.props.comments && _.some(this.props.comments, { id: hashId }))
57+
) {
58+
setTimeout(() => scrollToHash(scrollTo), 100)
59+
}
5260
}
5361
}
5462

0 commit comments

Comments
 (0)