Skip to content

Commit f7ea424

Browse files
committed
moved scrollTo to singleFeedContainer
1 parent 562d156 commit f7ea424

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/projects/detail/containers/FeedContainer.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import Section from '../components/Section'
3232
import SectionTitle from '../components/SectionTitle'
3333
import SingleFeedContainer from './SingleFeedContainer'
3434

35-
import { scrollToHash } from '../../../components/ScrollToAnchors'
3635
import { isSystemUser } from '../../../helpers/tcHelpers'
3736
import { checkPermission } from '../../../helpers/permissions'
3837
import PERMISSIONS from '../../../config/permissions'
@@ -216,15 +215,6 @@ class FeedView extends React.Component {
216215
const resetNewComment = prevFeed && prevFeed.isAddingComment && !feed.isAddingComment && !feed.error
217216
return this.mapFeed(feed, this.state.showAll.indexOf(feed.id) > -1, resetNewComment, prevProps)
218217
}).filter(item => item)
219-
}, () => {
220-
if (prevProps) {
221-
// only scroll at first time
222-
return
223-
}
224-
const scrollTo = window.location.hash ? window.location.hash.substring(1) : null
225-
if (scrollTo) {
226-
setTimeout(() => scrollToHash(scrollTo), 100)
227-
}
228218
})
229219
}
230220

src/projects/detail/containers/SingleFeedContainer.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import React from 'react'
1414
import _ from 'lodash'
1515

1616
import ScrollableFeed from '../../../components/Feed/ScrollableFeed'
17+
import { scrollToHash } from '../../../components/ScrollToAnchors'
1718

1819
const bindMethods = [
1920
'onNewCommentChange',
@@ -43,6 +44,14 @@ class SingleFeedContainer extends React.Component {
4344
})
4445
}
4546

47+
componentDidMount() {
48+
// we use this to just scroll to a feed block or comment in a feed block, if there is a url hash
49+
const scrollTo = window.location.hash ? window.location.hash.substring(1) : null
50+
if (scrollTo) {
51+
setTimeout(() => scrollToHash(scrollTo), 100)
52+
}
53+
}
54+
4655
render() {
4756
const nonBindProps = _.omit(this.props, bindMethods)
4857
const bindProps = _.zipObject(bindMethods, bindMethods.map((method) => this[method]))

0 commit comments

Comments
 (0)