mirror of
https://github.com/gurnec/removeddit.git
synced 2026-03-11 08:54:27 +00:00
Fix visits to full posts but with a bookmark/hash
Beforehand, only initial visits to single comments (permalinks) and internal links correctly scrolled to the bookmark/hash.
This commit is contained in:
parent
1e21ba474a
commit
536bccba2a
1 changed files with 10 additions and 7 deletions
|
|
@ -230,8 +230,10 @@ class Thread extends React.Component {
|
|||
// Set the scroll location to just below the post if not already set (only with permalinks)
|
||||
if (!this.props.location.hash)
|
||||
this.props.location.hash = '#comment-info'
|
||||
this.props.location.state = {scrollBehavior: 'smooth'}
|
||||
}
|
||||
|
||||
if (this.props.location.hash)
|
||||
this.props.location.state = {scrollBehavior: 'smooth'}
|
||||
}
|
||||
|
||||
// Updates this.curContigIdx based on URL's commentID if it's already downloaded.
|
||||
|
|
@ -337,12 +339,13 @@ class Thread extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
if (!loadingComments && !this.props.global.isErrored() && this.props.location.state?.scrollBehavior) {
|
||||
const { location } = this.props
|
||||
const id = location.hash.substring(1)
|
||||
if (id)
|
||||
document.getElementById(id)?.scrollIntoView({behavior: location.state.scrollBehavior})
|
||||
delete location.state
|
||||
const { location } = this.props
|
||||
if (location.state?.scrollBehavior && location.hash.length > 1 && !this.props.global.isErrored()) {
|
||||
const hashElem = document.getElementById(location.hash.substring(1))
|
||||
if (hashElem) {
|
||||
hashElem.scrollIntoView({behavior: location.state.scrollBehavior})
|
||||
delete location.state
|
||||
}
|
||||
}
|
||||
|
||||
if (this.nextAllCommentsFiltered != this.state.allCommentsFiltered)
|
||||
|
|
|
|||
Loading…
Reference in a new issue