mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-23 03:11:25 +00:00
Cleaning up scroll to comments
This commit is contained in:
parent
3870703b12
commit
5e5695c3ea
1 changed files with 13 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
import { Component, linkEvent, createRef, RefObject } from "inferno";
|
||||
import autosize from "autosize";
|
||||
import { Component, createRef, linkEvent, RefObject } from "inferno";
|
||||
import {
|
||||
AddAdminResponse,
|
||||
AddModToCommunityResponse,
|
||||
|
@ -117,7 +117,9 @@ export class Post extends Component<any, PostState> {
|
|||
this.fetchCrossPosts();
|
||||
if (this.state.commentId) {
|
||||
this.scrollCommentIntoView();
|
||||
} else if (new URLSearchParams(this.props.location.search).get('scrollToComments')) {
|
||||
}
|
||||
|
||||
if (this.checkScrollIntoCommentsParam) {
|
||||
this.scrollIntoCommentSection();
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +190,7 @@ export class Post extends Component<any, PostState> {
|
|||
this.scrollCommentIntoView();
|
||||
}
|
||||
|
||||
if (new URLSearchParams(this.props.location.search).get('scrollToComments') ) {
|
||||
if (this.checkScrollIntoCommentsParam) {
|
||||
this.scrollIntoCommentSection();
|
||||
}
|
||||
|
||||
|
@ -212,6 +214,12 @@ export class Post extends Component<any, PostState> {
|
|||
this.markScrolledAsRead(this.state.commentId);
|
||||
}
|
||||
|
||||
get checkScrollIntoCommentsParam() {
|
||||
return Boolean(
|
||||
new URLSearchParams(this.props.location.search).get("scrollToComments")
|
||||
);
|
||||
}
|
||||
|
||||
scrollIntoCommentSection() {
|
||||
this.state.commentSectionRef.current?.scrollIntoView();
|
||||
}
|
||||
|
@ -503,7 +511,8 @@ export class Post extends Component<any, PostState> {
|
|||
this.setState(this.state);
|
||||
setupTippy();
|
||||
if (!this.state.commentId) restoreScrollPosition(this.context);
|
||||
if (new URLSearchParams(this.props.location.search).get('scrollToComments') ) {
|
||||
|
||||
if (this.checkScrollIntoCommentsParam) {
|
||||
this.scrollIntoCommentSection();
|
||||
}
|
||||
} else if (op == UserOperation.CreateComment) {
|
||||
|
|
Loading…
Reference in a new issue