From: Dessalines Date: Tue, 2 Feb 2021 16:52:44 +0000 (-0500) Subject: Add preventDefaults to stop form submits on likes. Fixes #153 X-Git-Url: http://these/git/%7Bthis.props.imageSrc%7D?a=commitdiff_plain;h=398cdf682c269e71c7d7230324487ebc6c3842a9;p=lemmy-ui.git Add preventDefaults to stop form submits on likes. Fixes #153 --- 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 { 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 { 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 { ); } - 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 { setupTippy(); } - handlePostDisLike(i: PostListing) { + handlePostDisLike(i: PostListing, event: any) { + event.preventDefault(); if (!UserService.Instance.user) { this.context.router.history.push(`/login`); }