Fix comment jumping. Fixes #529 (#576)

This commit is contained in:
Dessalines 2022-02-14 14:10:11 -05:00 committed by GitHub
parent e13ab2ee46
commit a1125ddbf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -195,16 +195,7 @@ export class Post extends Component<any, PostState> {
document.addEventListener("scroll", this.commentScrollDebounced);
}
componentDidUpdate(_lastProps: any, lastState: PostState) {
if (
this.state.commentId &&
!this.state.scrolled &&
lastState.postRes &&
lastState.postRes.comments.length > 0
) {
this.scrollCommentIntoView();
}
componentDidUpdate(_lastProps: any) {
// Necessary if you are on a post and you click another post (same route)
if (_lastProps.location.pathname !== _lastProps.history.location.pathname) {
// TODO Couldnt get a refresh working. This does for now.
@ -548,6 +539,10 @@ export class Post extends Component<any, PostState> {
if (this.checkScrollIntoCommentsParam) {
this.scrollIntoCommentSection();
}
if (this.state.commentId && !this.state.scrolled) {
this.scrollCommentIntoView();
}
} else if (op == UserOperation.CreateComment) {
let data = wsJsonToRes<CommentResponse>(msg).data;