From 398cdf682c269e71c7d7230324487ebc6c3842a9 Mon Sep 17 00:00:00 2001
From: Dessalines <tyhou13@gmx.com>
Date: Tue, 2 Feb 2021 11:52:44 -0500
Subject: [PATCH] Add preventDefaults to stop form submits on likes. Fixes #153

---
 src/shared/components/comment-node.tsx | 6 ++++--
 src/shared/components/post-listing.tsx | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/shared/components/comment-node.tsx b/src/shared/components/comment-node.tsx
index e86a342..071c238 100644
--- a/src/shared/components/comment-node.tsx
+++ b/src/shared/components/comment-node.tsx
@@ -882,7 +882,8 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
     this.setState(this.state);
   }
 
-  handleCommentUpvote(i: CommentNodeI) {
+  handleCommentUpvote(i: CommentNodeI, event: any) {
+    event.preventDefault();
     let new_vote = this.state.my_vote == 1 ? 0 : 1;
 
     if (this.state.my_vote == 1) {
@@ -910,7 +911,8 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
     setupTippy();
   }
 
-  handleCommentDownvote(i: CommentNodeI) {
+  handleCommentDownvote(i: CommentNodeI, event: any) {
+    event.preventDefault();
     let new_vote = this.state.my_vote == -1 ? 0 : -1;
 
     if (this.state.my_vote == 1) {
diff --git a/src/shared/components/post-listing.tsx b/src/shared/components/post-listing.tsx
index b485a0a..41494c2 100644
--- a/src/shared/components/post-listing.tsx
+++ b/src/shared/components/post-listing.tsx
@@ -1155,7 +1155,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
     );
   }
 
-  handlePostLike(i: PostListing) {
+  handlePostLike(i: PostListing, event: any) {
+    event.preventDefault();
     if (!UserService.Instance.user) {
       this.context.router.history.push(`/login`);
     }
@@ -1187,7 +1188,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
     setupTippy();
   }
 
-  handlePostDisLike(i: PostListing) {
+  handlePostDisLike(i: PostListing, event: any) {
+    event.preventDefault();
     if (!UserService.Instance.user) {
       this.context.router.history.push(`/login`);
     }
-- 
2.44.1