From 83b8bcd5e14efc57c8156ec6b981b5b302ed27d8 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 16 Nov 2021 10:37:40 -0500 Subject: [PATCH] Fixing unload (#487) --- src/shared/components/post/post.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index 1213c5a..499330c 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -88,6 +88,7 @@ interface PostState { export class Post extends Component { private subscription: Subscription; private isoData = setIsoData(this.context); + private commentScrollDebounced: () => void; private emptyState: PostState = { postRes: null, postId: getIdFromProps(this.props), @@ -178,7 +179,8 @@ export class Post extends Component { componentWillUnmount() { this.subscription.unsubscribe(); - document.removeEventListener("scroll", this.trackCommentsBoxScrolling); + document.removeEventListener("scroll", this.commentScrollDebounced); + window.isoData.path = undefined; saveScrollPosition(this.context); } @@ -189,10 +191,8 @@ export class Post extends Component { ); autosize(document.querySelectorAll("textarea")); - document.addEventListener( - "scroll", - debounce(this.trackCommentsBoxScrolling, 100) - ); + this.commentScrollDebounced = debounce(this.trackCommentsBoxScrolling, 100); + document.addEventListener("scroll", this.commentScrollDebounced); } componentDidUpdate(_lastProps: any, lastState: PostState) { -- 2.44.1